Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:09
opening iframe "frameset"
Poster: rstarr
Dated: Monday September 29 2003 - 18:23:44 BST
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!
PLEASE HELP!!
Poster: rstarr
Dated: Monday September 29 2003 - 20:52:29 BST
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:)
Poster: mfurf
Dated: Tuesday September 30 2003 - 0:24:45 BST
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
Poster: Hergio
Dated: Tuesday September 30 2003 - 2:26:19 BST
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:
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"];
}
{
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"];
}
iframe src
Poster: rstarr
Dated: Tuesday September 30 2003 - 6:36:52 BST
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.
Poster: Hergio
Dated: Tuesday September 30 2003 - 12:54:01 BST
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?