Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 24th, 2002, 12:46 AM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
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

Reply With Quote
  #2  
Old July 24th, 2002, 03:50 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #3  
Old July 24th, 2002, 11:22 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
From memory it's document.frames[0].location.href = 'somepage.html' etc...

Reply With Quote
  #4  
Old July 29th, 2002, 11:28 AM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
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.

Reply With Quote
  #5  
Old July 29th, 2002, 09:37 PM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
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?

Reply With Quote
  #6  
Old July 30th, 2002, 09:34 AM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
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>
Or, if you do want to write the frameset with JS, it'd be something like this:
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.

Reply With Quote
  #7  
Old July 30th, 2002, 11:02 PM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
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

Reply With Quote
  #8  
Old July 30th, 2002, 11:14 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
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>

Reply With Quote
  #9  
Old July 31st, 2002, 10:13 PM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
nope, it didn't work. Must I put the function in the head tag?Or was it right? I did just that.

Reply With Quote
  #10  
Old August 6th, 2002, 07:28 AM
rajeevrao rajeevrao is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Bangalore
Posts: 30 rajeevrao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to rajeevrao
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > How do I 'talk' to the frameset?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT