The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to refer to parent URL from iFrame contained in parent URL's page
lunghd
post Sep 18 2006, 08:15 PM
Post #1


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



Hello - I'm a total cut & paste hack with limited knowledge who's learning as he goes so please be kind & excuse if I use the wrong terminology...

I'm setting up some iFrames on my site where that I can alter their contents globally across the entire site rather than modify them page by page.
For now, the iFrames simply will contain a page index, google search & a print button. The "print button" feature really isn't important but is an easy tool for me to learn this with.

Right now - what I'm primarily trying to learn is how to call a up the parent page's URL to be used by various functions "called up / contained within" an iFrame.

In the example I'm working on, the "Print This Page" button contained inside the iFrame prints nothing but the contents of the iFrame itself. Ok - that makes sense & I can understand why it does that... it's contained inside it's own "page" (the iFrame itself) and it's doing what it's made to do... "Print this page" (the iFrame's contents).

What I am hoping to learn how to do is create a means to call up the parent page's URL which originally contained the iFrame - no matter what page is actually loaded by the visitor. Only a few of my pages were set up this way before I found this glitch in my grand scheme... but here is an example page showing things as they are:

Example page: http://www.lunghd.com/Tech_Articles/Body/Hinges.htm

And the iFrame page currently to be loaded globally: http://www.lunghd.com/index_frames/iFrame_Index.htm


There are tantalizing bits out there on how to do nearly the reverse - reading or calling up things contained inside an iFrame, displaying different contents within an iFrame, etc... but I seem to be trying to accomplish the opposite by calling the parent page's URL to direct an action carried out by a script inside the iFrame.


I appreciate any insight, guidance or severe beatings.

(FWIW... I use HotMetalPro6.0. which doesn't comply with anything more modern than the jawbone of an antelope.)

This post has been edited by lunghd: Sep 18 2006, 08:17 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 18 2006, 09:03 PM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



With JavaScript? You refer to the parent window with 'parent'. If you want to reach one frame from another frame you have to step all the way up (parent.parent.parent...) until your reach the top window and then down again using the frame names. A shortcut is to use 'top' that always refers to the top window.

Example.
parent.parent.otherwindow is the same as top.otherwindow.

Since you don't use nested frames, only iframes, 'parent' will refer to the top window.

It's explained in more detail here: http://www.quirksmode.org/js/frameintro.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
lunghd
post Sep 19 2006, 09:56 AM
Post #3


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



QUOTE(pandy @ Sep 18 2006, 10:03 PM) *

With JavaScript? You refer to the parent window with 'parent'. If you want to reach one frame from another frame you have to step all the way up (parent.parent.parent...) until your reach the top window and then down again using the frame names. A shortcut is to use 'top' that always refers to the top window.

Example.
parent.parent.otherwindow is the same as top.otherwindow.

Since you don't use nested frames, only iframes, 'parent' will refer to the top window.

It's explained in more detail here: http://www.quirksmode.org/js/frameintro.html



Thank you! (And thanks for moving this to the proper forum - My apologies!)

Yes, js in this example since the generic button I'm learning with is also in js. Same with some other widgets that I would like to try are also in js. From what I can see - that page looks like an excellent tutorial for me on this. Simple and without over-complicated examples - just basics I can build on.

I've googled for days looking for a simple explanation of this but not having the nomenclature I've been unable to phrase the search correctly to get results to get something understandable to learn from. Just the move to 'client-side' forum helps me to know why my google search wasn't getting good results - thanks!


Thanks again - I appreciate that page more than you know. I'll take it as far as I can then go from there! smile.gif

This post has been edited by lunghd: Sep 19 2006, 10:17 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Sep 19 2006, 12:33 PM
Post #4


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



That's always the problem. It's hard to ask a question when you don't know how to phrase it. In this case "Javascript frames" will find a lot. Possibly throw "tutorial" in too.

QUOTE
From what I can see - that page looks like an excellent tutorial for me on this.

For me too! It's a lifelong plan of mine to learn JS properly. smile.gif
ppk's site has always been a great resource. I was surprised yesterday to see that he has revamped it and added a lot of material. And written a book too! Not all tutorial sites offer sound advice. You can trust quirksmode.org.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
lunghd
post Oct 3 2006, 12:36 PM
Post #5


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



Heh - what I learned is that it was easier to learn CSS and the fine art of "includes"! biggrin.gif I didn't figure out the parent thing (which explains why my 9 year old son is still giving me fits on a daily basis... blink.gif ) but have stumbled on some parts of the answer to my original question now that I've learned a small bit of CSS. Going to 'includes' meant tossing the iFrame out but gave me a much better solution and opened up a whole new world for my site's future. As soon as I solve a few minor formatting issues with the links I want to put on some of the pages I'll be in business.

I just wanted to drop back here and say thanks because that page you recommended led me to another & to another & to a "Sams: Teach yourself JavaScript" book I purchased & eventually to a CSS template that I played with for days and days... (and adopted after tons of modifications!) and a pile of script examples & then something clicked. excl.gif

Now I can go back to the beginning with the js since things are starting to make a bit more sense. If nothing else, I need to learn the nomenclature so I can ask the questions without getting really, REALLY bizzare results from Google. wink.gif

Thanks again! I'll be using this site a LOT now!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 3 2006, 04:59 PM
Post #6


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



That's cool. Nice of you to come back and tell us. smile.gif

Yeah, includes are the way to go if including files was what you were after. Frames are to more trouble than use, but I ddn't want to say that before. happy.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
lunghd
post Oct 9 2006, 04:42 PM
Post #7


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



QUOTE(pandy @ Oct 3 2006, 05:59 PM) *

That's cool. Nice of you to come back and tell us. smile.gif

Yeah, includes are the way to go if including files was what you were after. Frames are to more trouble than use, but I din't want to say that before. happy.gif



Yup. Includes-R-Us now, but I had no clue that was what I was after. laugh.gif

Learning includes solved the problem quite nicely! I can quite gleefully make those global changes I was after across all my Tech Pages at once rather than grumpily editing those old pages one by one.... A very handy trick. Hardest thing was racking my brains to create new site templates with the proper includes built in so I wouldn't have to go back and add them later except for specific cases. I'm in the process of converting the html over to shtml & CSS now. It'll probably take me another month to go back and get the pages to conform to CSS standards after that - for now, I'm having to leave a lot of html text tags in place in the content divs. Everything else is an include and can be edited in an eyeblink! biggrin.gif

Hey - getting o.t. so it's over to the CSS area to axt another question that I have no clue how to axt. blink.gif

Thanks again! smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 9 2006, 05:00 PM
Post #8


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



smile.gif

QUOTE
I'm in the process of converting the html over to shtml

Just wondering, do you know that you don't have to rename pages to .shtml (and screw old links up)? You can make the server parse .html files for SSI.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
lunghd
post Oct 9 2006, 10:41 PM
Post #9


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



QUOTE(pandy @ Oct 9 2006, 06:00 PM) *

smile.gif

QUOTE
I'm in the process of converting the html over to shtml

Just wondering, do you know that you don't have to rename pages to .shtml (and screw old links up)? You can make the server parse .html files for SSI.



Nope. News to me. I'm happily converting as I go.

Hmmm. If you tell me more, will I bang my head against the wall until I re-live the 70's? laugh.gif

Makes sense that this could be done (and vaguely remember this from DOS batch file processing...) but keep in mind that I'm an antique... to me, COBOL was keen fun and cutting edge technology means having a good disposable razor in the morning... The thought simply never occurred to me.

OK... Go ahead... Clue me in and make my head explode. Just don't lean too close to your monitor.

This post has been edited by lunghd: Oct 9 2006, 10:43 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 10 2006, 05:38 AM
Post #10


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



No, nothing complicated. Just a line in your .htaccess file. Something like this.

CODE
AddHandler server-parsed     .html .htm .shtml


If you don't have a .htaccess file or know what it is, it's sort of a per directory configuration file on Apache (you can google for more).

If you have one already, add the line above to it. If not, create a text file with just that line, name it exactly ".htaccess" and upload it to your document root. Done. cool.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 10 2006, 05:47 AM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,822
Joined: 9-August 06
Member No.: 6



QUOTE
I'm a total cut & paste hack with limited knowledge

Oops! Maybe I should tell you that errors in the .htaccess file have the potential to screw your site up. tongue.gif

Don't make typos. One space or several to separate things doesn't matter, but don't use linebreaks in directives. One thing a line. Comments are prefixed with a hash sign, like this

CODE
### This makes all HTML parsed for SSI ###
AddHandler server-parsed     .html .htm .shtml
# Wee - it works!


This would be bad:
AddHandler server-parsed
html .htm .shtml

So would this:
This is a comment (not!)
AddHandler server-parsed .html .htm .shtml
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
lunghd
post Oct 10 2006, 08:37 AM
Post #12


Newbie
*

Group: Members
Posts: 18
Joined: 18-September 06
Member No.: 160



QUOTE(pandy @ Oct 10 2006, 06:47 AM) *

QUOTE
I'm a total cut & paste hack with limited knowledge

Oops! Maybe I should tell you that errors in the .htaccess file have the potential to screw your site up. tongue.gif

Don't make typos. One space or several to separate things doesn't matter, but don't use linebreaks in directives. One thing a line. Comments are prefixed with a hash sign, like this

CODE
### This makes all HTML parsed for SSI ###
AddHandler server-parsed     .html .htm .shtml
# Wee - it works!


This would be bad:
AddHandler server-parsed
html .htm .shtml

So would this:
This is a comment (not!)
AddHandler server-parsed .html .htm .shtml



Yep, I have a .htaccess file. Two actually. (More on that in a moment.) Had to the primary one for a mime type eons ago (if I recall correctly). I couldn't get some odd file I was playing with to work without it. I just now peeked back into it & it's empty... 11 bytes with no content. I don't recall blanking out the .htaccess file. but may have done so when I deleted whatever I was playing with at the time that needed it.

The second one is named dot.htacess & is specifically linked to an on-site search engine & is located in the sub-directory with the search engine. If I understand correctly, it can't interfere with anything else given it's filename prefix of 'dot' and being located in the sub-directory. (I'm ditching that search engine given the advent of Google's search engine... *sigh* Add that to next week's list.)

I'll add those lines to the .htacess file and see how the magic works.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 22nd February 2018 - 11:26 PM