Forum Moderators: open

Message Too Old, No Replies

document.write() problem

script to load orphan pages into their parent frameset

         

lisalisalisa

8:45 pm on Dec 27, 2003 (gmt 0)

10+ Year Member



If anyone can help, I would soooooo appreciate it!

This is what is happening. I'm linking a button within a flash page to a separate file containing a frameset (a topFrame and a mainFrame). This flash page acts as an intro/home page and won't be used much after the user is within the site. A new navigation system within the frameset, topFrame, will then be the primary nav system.

frameset is "secFrameset"
topFrame is "topFrame"
bottomFrame is "mainFrame"

I applied this code and all seems to work well except one item, the document.write()code in the frameset main page "secFrameset". Please note that my javascript capabilities are almost null.

<html>
<head>
<title>secFrameset</title>
</head>

<script language="JavaScript" type="text/javascript">

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)

document.write('<frameset rows="122,*" cols="*" framespacing="0" frameborder="NO" border="0"><frame src="topFrame.htm" name="topFrame" frameborder="no" scrolling="NO" bordercolor="#FFFFFF"><frame src="services.htm" name="mainFrame" frameborder="no" scrolling="auto" bordercolor="#FFFFFF"><frame src="' + contentURL + '" name="content"><\/frameset>')

</script>

</html>

I have several orphan pages, Ex. services.htm, about.htm, etc., designated to the mainFrame, and I don't know the correct way to list the additional pages in the "document.write(). I have tried several different ways and nothing works.

A special thanks in advance for your help.

tedster

12:21 am on Dec 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For reference, we are talking about Message #21 here:
[webmasterworld.com...]

There is some good news here -- the way this javascript works is that there is no need to change ANYTHING to have it work for an indefinite number of potentially orphaned content pages. Just customize it once for your specific frames layout and that's it.

Here's the logic for this approach. There are two scripts: one you place on each and every potentially orphaned page and one you use in the frameset document.

1. The script for each content page checks to see if the page is in a frameset. If it is orphaned, then the script redirects to the frameset page instead, but it also appends its own url at the end in a query string, after the "?"

So each page that has the orphan script running will append its own URL to the tail end of the frameset.

Here's that script:

passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage

2. The second script is on the frameset page - this is the code you have in your post. This script strips the "content page" information off the end of the full URL and creates contentURL. The frameset's document.write() sets the src attribute to contentURL, which should automatically be the orphaned page's address. You don't need to change the docuemnt.write() script at all.

Just make sure you have the first script installed on every possible orphaned page. Then your links can be set directly to the content page's URL with no concern for the parent frameset at all.

lisalisalisa

9:20 am on Dec 28, 2003 (gmt 0)

10+ Year Member



ok, what you said makes sense but I'm still having problems.

Is this code correct from the flash file linking to the html file? I'm not sure that "name" is the right syntax.

on(release){
getURL ("secFrameset.htm?name=about.htm");
}

tedster

5:08 pm on Dec 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's easier than that. Just link directly to the content page. The javascript will then take over and place about.html into the parent frameset; you don't need to do that in your linking code.