opening iframe "frameset"

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
rstarr
Advanced
Advanced
Posts: 11
Joined: Fri Oct 25, 2002 5:07 pm

opening iframe "frameset"

Post by rstarr »

I need my menu to link to distinct pages that each have a distinct iframe. How do I call up a page like the following:
filename.html?http://www.iframesrc.html
whereby the framesrc fills the iframe on that page?
(NB: each page several iframe src's)
Urgent!
Thank you!
rstarr
Advanced
Advanced
Posts: 11
Joined: Fri Oct 25, 2002 5:07 pm

PLEASE HELP!!

Post by rstarr »

If you can help me with the above problem, it would be greatly appreciated. I have a deadline in an hour. Aagghh....
Thanks in advance:)
mfurf
Super Advanced
Super Advanced
Posts: 74
Joined: Tue Sep 23, 2003 12:30 am
Location: Purling NY
Contact:

Post by mfurf »

Not being an iframes expert but in learning mode myself as I switch over from framesets to iframes I'm only jumping in here because of the sense of urgency in your posting.

Do you have the iframe embedded in the filename.html file with src=http://www.iframesrc.html in the code?

If so, it would seem to me that the line

aI("text=Your Text;url=filename.html;target=_blank;");

would open it in a new window and the iframe would load with its proper content. But this explanation seems too facile to me, as if I'm not properly understanding what you want to do. /mfurf
Oh Saratoga!
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Man is it a WHOLE lot easier if you have ASP, PHP, or coldfusion, but it can be done with straight javascript. See this. Change the frameID value in the updateframe function to that of your iframe you want to update. Then call updateFrame from your pages onload event, like this

<BODY onLoad="updateFrame();">

It will be looking for a URL in the form of http://www.domain.com/pagename.html?url ... .apple.com

Put this in your HEAD of the doc.

Code: Select all

function getKeys() 
{
	var keys = new Object();
	var queryString = location.search.substring(1); 
	var keyPairs = queryString.split("&"); 
	
	for(var i = 0; i < keyPairs.length; i++) 
	{
		var position = keyPairs[i].indexOf('='); 
        if (position == -1) continue; 
	    
	    var keyname = keyPairs[i].substring(0, position ); 
		
	    var keyvalue = keyPairs[i].substring(position + 1); 
	    keys[keyname] = unescape(keyvalue); 
	}
	return keys;
	
  }

function updateFrame()
{
                frameID = "myiframe";
	queryKeys = getKeys();
	document.all[frameID].src = queryKeys["url"];
}
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
rstarr
Advanced
Advanced
Posts: 11
Joined: Fri Oct 25, 2002 5:07 pm

thanks

Post by rstarr »

I'll give this a try.
rstarr
Advanced
Advanced
Posts: 11
Joined: Fri Oct 25, 2002 5:07 pm

iframe src

Post by rstarr »

so far so good...(Thanks so much for your help- yes php would be better) What do I put as my iframe src in my main page that is calling dynamic iframe content?

something like:
<iframe src="javascript:updateFrame()" width= "645" frameborder="0" height="248" scrolling="auto" id="myiframe" name="myiframe">
Your browser does not support inline frames. To view this page,
correctly, you'll need Internet Explorer 5 or later or Netscape 6 or later.
</iframe>

doesn't work.
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Naw putting that in the src field won't do it. You need to put something, anything, else in the src field as a temporary filler. If you just say src="", that'll work too, then the iframe will initially come up blank. Or if you have a default page, put it in there. In your page, you have a BODY tag, right? In that is where you call the function. So it would say...
<BODY onLoad="updateFrame()">
This will load the page (with your iframe loading the default or blank page) and once its finished, it will call updateFrame which will go to your URL, find the url= key and take that url and throw it at the iframe. Got it?
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply