fewtrem Posted July 26, 2006 Share Posted July 26, 2006 Hi. I'm pramarily using php for a little project I was trying.The problem is that I wanted javascript to run in one frame sothat it could control the other frame and change ithe other frame's location.This works fine when the page is run first time, but after the first frame is reloaded (due to php) the javascript in this frame does not recognise the code below:parent.frames.site.window.location which becomes undefined!!Basically, I want the first frame to know the address of the other frame at all times and for it to be able to change the other frame's location (which works).I managed to get the user to simply type in the address and the other frame will move to it but if the user moves around within the main frame then the other frame will lose track of where they are. It didn't seem to like javascript timers constantly updating the location. I'm trying to think of a simple way round it or if i've missed something about javascript. Any alternative methods would be welcome.Please tell me if you would like to help but need more info.ThanksDavidthe little project is at[url=http://www.scd.hostiz.com/FewtraWeb/]http://www.scd.hostiz.com/FewtraWeb/[/url] Quote Link to comment Share on other sites More sharing options...
bltesar Posted July 27, 2006 Share Posted July 27, 2006 more information is needed. Provide the basic structure of your frameset and frames. Quote Link to comment Share on other sites More sharing options...
fewtrem Posted July 28, 2006 Author Share Posted July 28, 2006 Okay, but its a bit of a messy script. DO NOT BOTHER TRYING TO READ IT ALL! I just want to know if what I am trying to do is possible, and if so how!Frameset: <html><head><link rel="SHORTCUT ICON" href="favicon2.ICO"><link rel="SHORTCUT ICON" href="favicon.gif"><title>FewtraWeb from Fewtrem Europa</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><frameset cols="23%,*"> <frame name="viewer" noresize src="http://scd.hostiz.com/FewtraWeb/fewtraweb.php?a=http://www.google.com"> <frame name="site" noresize src="http://www.google.com" ></frameset><noframes> <body bgcolor="#FFFFFF" text="#000000"></body></noframes> </html>Frame Viewer (SCRIPT) - where the problem comes from Following is called by clicking on get addressfunction checkaddress(){alert(addresshere + parent.frames.site.window.location);if (addresshere != parent.frames.site.window.location){alert("match gone");addresshere = parent.frames.site.window.location;document.browsing.adbar.value = parent.frames.site.window.location;document.comment.adbar2.value = parent.frames.site.window.location;}} Frame viewer(PHP) FULL VERSION <?php $firsterror = "Page has loaded. "; $reload = "go()"; $goagain = ""; if(!$b){ $b = ""; } $conn = @mysql_connect("localhost", "fewtrem", "hola") or die("Connection to MySQL failed"); $dbopen = "fewtrem_main"; $rs = @mysql_select_db( $dbopen ,$conn ) or die("Cannot open FewtraWeb database ".$dbopen." failed"); if($rip){ if($rip == "TRUE"){ $reload = "alert(parent.frames.site.window.location);"; $goagain = "checkaddress()"; } } if ($_POST['adbar']){ $a = $_POST['adbar']; } if($_POST['name2']){ $b = $_POST['name2']; } if ($add){ if($add == "TRUE"){ $a = $_POST['adbar2']; $b = $_POST['name']; $c = $_POST['text']; $d = "insert into fewtraweb ( address , name , comment ) values ( \"".$a."\" , \"".$b."\" , \"".$c."\" )"; $poland = @mysql_query($d, $conn); if ($poland == false){ $list .= "Failed to add comment<BR>"; } } } $sql = "select * from fewtraweb where address=\"".$a."\""; $rs2 = mysql_query( $sql,$conn); $u2 = 0; for ($i = 0; $i < mysql_num_rows ( $rs2 ); $i++){ while( $row = mysql_fetch_array( $rs2 )){ $u2 += 1; $list .= $row[$i+1]." <I></B>said</I><B> ".$row[$i+2]."<br>"; } } if ($list == ""){ $firsterror .= "No results for this page. "; } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><link type="text/css" rel="stylesheet" href="defaultstyle.css">SCRIPT (FULL):<script type="text/javascript"><!--var addresshere = "<?php echo($a) ?>";function go(){parent.frames.site.window.location = "<?php echo($a) ?>";}function checkaddress(){alert(addresshere + parent.frames.site.window.location);if (addresshere != parent.frames.site.window.location){alert("match gone");addresshere = parent.frames.site.window.location;document.browsing.adbar.value = parent.frames.site.window.location;document.comment.adbar2.value = parent.frames.site.window.location;}}var msg1 = parent.frames.site.window.location//--></script>DOCUMENT:<title>FewtraWeb First Edition</title><link rel="SHORTCUT ICON" href="favicon2.ICO"><link rel="SHORTCUT ICON" href="favicon.gif"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="#204A79" text="#25E0AD" link="#92EFD6" vlink="#92EFD6" alink="#92EFD6" onload="<?php echo($goagain) ?>"><script type ="text/javascript"><?php echo($reload)?></script><p><font size="4" face="Arial, Helvetica, sans-serif"><b>FewtraWeb              <a href="<?php echo($a) ?>" target="_parent">close</a><br> </b><i>a connected web browser</i></font><font face="Arial, Helvetica, sans-serif" size="3"><br> </font> <form name="browsing" action="fewtraweb.php?b=<?php echo($b) ?>&" method="post"><font size="4" face="Arial, Helvetica, sans-serif">address:</font> <input type="text" class="textbox" name="adbar" size="35" value="<?php echo($a) ?>"> <input type="hidden" class="textbox" name="name2" size="35" value="<?php echo($b) ?>"> <br> <input type="submit" class="formbutton" name="Submit" value="go there now >"></form><form name="riping" action="fewtraweb.php?b=<?php echo($b) ?>&rip=TRUE&" method="post"> <input type="hidden" class="textbox" name="name2" size="35" value="<?php echo($b) ?>"> <input type="submit" class="formbutton" name="Submit" value="< rip address"></form><p><font size="4" face="Arial, Helvetica, sans-serif"><b>FewtraWeb References<br> <?php echo($list) ?> </b></font><br> <br> <form name="comment" action="fewtraweb.php?b=<?php echo($b) ?>&add=TRUE&" method="post"> <input type="hidden" class="textbox" name="adbar2" size="35" value="<?php echo($a) ?>"> <font size="4" face="Arial, Helvetica, sans-serif">name:</font> <input type="text" class="textbox" name="name" size="35" value="<?php echo($b) ?>"> <br> <font size="4" face="Arial, Helvetica, sans-serif">comment:</font> <input type="text" class="textbox" name="text" size="35" value=""> <br> <input type="submit" class="formbutton" name="Submit" value="blog it >"></form><br> <br><font face="Arial, Helvetica, sans-serif" size="1">with thanks to the people at <a href="http://www.hostiz.com">Hostiz</a> for hosting this service</font></body><HEAD><link type="text/css" rel="stylesheet" href="defaultstyle.css"></HEAD></html>Thanks Quote Link to comment Share on other sites More sharing options...
bltesar Posted July 28, 2006 Share Posted July 28, 2006 I really couldn't sort through all your code, but I can tell you a few things that might help. First of all, I'm not sure, but I think 'go' is a reserved keyword in JavaScript. I recall naming something 'go' and it didn't work. I've created similar setups and I discovered that different browsers use different object models and the correct path to your frame can vary. Try this -if(top.site){ var rightframe=top.site;}else{ var rightframe=parent.frames[1];}use rightframe in place of your parent.frames.site Quote Link to comment Share on other sites More sharing options...
fewtrem Posted August 1, 2006 Author Share Posted August 1, 2006 Thanks very much - I really wasn't expecting anyone to sort through that code. Thanks for the code I will try it laterI don't think go is reserved in javascript - or at least it never used to be. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.