want Child frame to always load with parent?

P

Paul

HI! I want to be able to always load the parent if the child frame page is
access by a link in a users bookmark or if its on a search engine.
At the moment I am getting links being displayed in search engines are only
pulling up the child frame without the parent frame page.

The added the script below and change "getElementById" to "getElementByName"
because my parent frame page uses Name. and the parent child frame is called
"mainFramePages". The script is inside the child page.

What am I doing wrong.

<script type="text/javascript">
var loc_var=this.location.href;
if(loc_var.indexOf('?addr='!=-1)){
var loc_arr=loc_var.split('?addr=');
document.getElementByName('mainFramePages').src=loc_arr[1];
}
</script>

Paul
 
R

Ronx

document.getElementByName('mainFramePages').src returns an error - method
not supported.

A possible alternative is:

The script in the child pages should be similar to:

<script type="text/javascript">
if (window == top) location.href = "/default.htm?pg=" +
escape(document.location.href)
</script>
where default.htm is the frameset page, in the root folder of the website.

In the frameset page use JavaScript to get the source page and write the
frameset. As an example:

<head>
<title>Test frames page</title>
<script type="text/javascript">
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return unescape(qs[1]);
}

var loc_arr = getQuerystring("pg")

if (loc_arr == "") {
loc_arr = "default_content_page.html";
}
</script>

</head>

<script type="text/javascript">
document.write('<frameset cols="150,*">');
document.write('<frame src="navigation.html" name="nav">');
document.write('<frame srv="'+loc_arr+'" name="mainFramePages">');
document.write('</frameset>');
</script>

</html>

--
Ron Symonds
Microsoft MVP (Expression)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top