|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do I 'talk' to the frameset?
I have the following simple browser detection script:
var browserName = navigator.appName; var browserVer = parseInt(navigator.appVersion); if (browserName == "Netscape" && browserVer >= 3) { // command frameset to point to leftnn.php } if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) { // command frameset to point to leftie.php } ------------------------------------------------------------------------ And then, I have the following: <frameset rows="80,*" cols="*" frameborder="NO" border="0" framespacing="0"> <frame src="top.php" name="top" noresize marginwidth="0" marginheight="0" scrolling="NO" frameborder="NO"> <frameset cols="129,*" rows="*" border="0" framespacing="0" frameborder="NO"> <frame src="" name="left" marginwidth="0" marginheight="0" frameborder="NO" noresize scrolling ="AUTO"> <frame src="something.php" name="maincontent" noresize marginwidth="0" marginheight="0" scrolling=" AUTO" frameborder="NO"> </frameset> </frameset> -------------------------------------------------------------------- As you can see, the frame named 'left' has an empty src property value. I want to cause 'left' to call different php files accordingly based on the browser version and type detected. How do i do that? I tried something like parent.document.getElementById("left").src = "leftnn.php"; but it did not work. Please help. Thank you |
|
#2
|
|||
|
|||
|
hmm, i dont know exactly how to do it, but what i would suggest is making the scritp so it checks it during load, in the body tag as a function, then set the value of the src on the frame tag.
something like document.frame.left.src.value = "name.php"; i think something like that will work |
|
#3
|
|||
|
|||
|
From memory it's document.frames[0].location.href = 'somepage.html' etc...
|
|
#4
|
|||
|
|||
|
mytch is correct. It can be any of these
parent.frames[i].location.href = 'page.htm'; Where 'i' is the index of the frame within the frameset --or-- parent.frames.frameName.location.href = 'page.htm'; Where 'frameName' is the frame's DOM name (ie: left) --or-- parent.frames(frameName).location.href = 'page.htm'; Where 'frameName' is the frame's DOM name (ie: left) Note: Use of 'parent' in place of 'document' is recommended, in case you ever call this code from a page within the frameset Or you could write the frameset to the page with javascript and stick in variables where you need them. I can provide an example if you wish. Last edited by beetle18 : July 29th, 2002 at 11:31 AM. |
|
#5
|
|||
|
|||
|
perhaps beetle, you might want to enlighten me on your last line about sticking variables....
I found out that the src proporty of frame in JS is not settable, meaning there is no way to change the html frame src dynamically. moreover, according to DOM hierarchy, the frame is under window object but above document object. Here is what i did: function redirectPage() { var browserName = navigator.appName; var browserVer = parseInt(navigator.appVersion); if (browserName == "Netscape" && browserVer >= 3) { parent.frames.left.location.href = "leftns.php"; } if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) { parent.frames.left.location.href = "leftie.php"; } } <frames src="javascript:'RedirectPage()'"> but to no avail? Am i calling the function right? |
|
#6
|
|||
|
|||
|
You can't assign a javascript return variable to an HTML attribute that way. the "javascript:code" convention is only for href attributes on anchor tags.
Any of the code I put in my last post would have to be activated AFTER the loading of the FRAMESET Code:
</HEAD>
<FRAMESET>
{....frames....}
</FRAMESET>
<script> {...All that code here....} </script>
<BODY>
Code:
<script language="javascript">
// Simple browser check
var framePage = (document.all)? "ie_page.htm": "ns_page.htm";
</script>
</head>
<script language="javascript">
document.writeln('<framset cols="150,*">');
document.writeln('<frame name="leftFrame" src="left.htm" />');
document.writeln('<frame name="mainFrame" src="'+framePage+'" />'):
document.writeln('</frameset>');
</script>
<body>
Last edited by beetle18 : July 30th, 2002 at 09:38 AM. |
|
#7
|
|||
|
|||
|
Thank you so very much beetle.
it worked very well.....however, only for the second method. Though problem is solved, i am curious as to why the first method didn't work. Here it is (what i understand and did according to your first recommended solution): <html> <head> <title>Hello</title> </head> <frameset id="OuterFrameset" rows="80,*" cols="*" frameborder="NO" border="0" framespacing="0"> <frame id="Frame1" src="top.php" name="top" noresize marginwidth="0" marginheight="0" scrolling="NO" frame border="NO"> <frameset id="InnerFrameset" cols="129,*" rows="*" border="0" framespacing="0" frameborder="NO"> <frame id="Frame2" src="" name="left" marginwidth="0" marginheight="0" frameborder="NO" noresize scrol ling="AUTO"> <frame id="Frame3" src="somepage.php" name="maincontent" noresize marginwidth="0" marginheight="0" scrolling="AUTO" frameborder="NO"> </frameset> </frameset> <SCRIPT language="JavaScript" type="text/javascript"> <!-- var browserName = navigator.appName; var browserVer = parseInt(navigator.appVersion); if (browserName == "Netscape" && browserVer >= 3) { parent.frames.left.location.href = "leftns.php"; } if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) { parent.frames.left.location.href = "leftie.php"; } //--> </SCRIPT> <noframes> <body> </body> </noframes> </html> What do you think?
__________________
Beginner |
|
#8
|
|||
|
|||
|
Try this:
Code:
<SCRIPT language="JavaScript" type="text/javascript">
<!--
function initFrames()
{
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
if (browserName == "Netscape" && browserVer >= 3) {
parent.frames.left.location.href = "leftns.php";
}
if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) {
parent.frames.left.location.href = "leftie.php";
}
}
//-->
</SCRIPT>
<noframes>
<body onLoad="initFrames();">
</body>
</noframes>
</html>
|
|
#9
|
|||
|
|||
|
nope, it didn't work. Must I put the function in the head tag?Or was it right? I did just that.
|
|
#10
|
|||
|
|||
|
tim .. just do with ASP
if your server supports ASP .. just forget about those (complicated ?) javascripts ..
Use the browser capabilities component and then redirect accordingly .. easy as pie .. heh ??
__________________
Rajeev |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > How do I 'talk' to the frameset? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|