Loading a page in a frame

R

RichardM

I have the following HTML page (see bottom of message) that consists of a
frame with two windows. The top window is always the menu, and the bottom
window is by default a document named "TheDesc.htm". However, if another
page is called, I want to display this new page into the bottom frame in
place of "TheDesc.htm".

My problem is with the third document.write command in the SCRIPT section.

document.write('<FRAME SRC="+%20(%20location.search%20?
location.search.substring(1):" TheDesc.htm") + NAME="MAIN">');

I get an error message when calling another page, like:

http://www.mysite.com/myframe.html?http://mysite.com/newpage.htm

Any idea what is wrong with this line?

BTW, I got this script from a web site, so I'm not sure I fully understand
this like. What %20 means.

Richard


<HTML>
<HEAD>
<SCRIPT language="JavaScript">
document.write('<FRAMESET FRAMEBORDER="0" BORDER="0" FRAMESPACING="0"
ROWS="121,85%">');
document.write('<FRAME SRC="TheMenu.htm" NAME="MENU" MARGINWIDTH="0"
MARGINHEIGHT="0">');
document.write('<FRAME SRC="+%20(%20location.search%20?
location.search.substring(1):" TheDesc.htm") + NAME="MAIN">');
document.write('<\/FRAMESET>');
</SCRIPT>
</HEAD>
<FRAMESET FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" ROWS="125,84%">
<FRAME SRC="TheMenu.htm" NAME="MENU" MARGINWIDTH="0" MARGINHEIGHT="0">
<FRAME SRC="TheDesc.htm" NAME="MAIN" MARGINWIDTH="8">
<NOFRAMES>
<BODY>
Viewing this page requires a browser capable of displaying frames.
</BODY>
</NOFRAMES>
</FRAMESET>
</HTML>
 
M

Michael Winter

[snip]
My problem is with the third document.write command in the SCRIPT
section.

document.write('<FRAME SRC="+%20(%20location.search%20?
location.search.substring(1):" TheDesc.htm") + NAME="MAIN">');

That statement appears to be complete rubbish. What you probably want is

document.write('<frame src="' + location.search.substring( 1 ) +
'" name="MAIN">');

[snip]
BTW, I got this script from a web site, so I'm not sure I fully
understand this like. What %20 means.

The number of usable characters in a URI is limited. To escape restricted
characters, you take the character code, convert it to hexadecimal, and
prefix a percentage symbol. %20 represents a space.
<SCRIPT language="JavaScript">

SCRIPT elements require a type attribute, which negates the need for the
language attribute. The above should read

<script type="text/javascript">

[snip]

Mike
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top