470,841 Members | 1,067 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

problem with insertAdjacentHTML

Hi all,

I am trying to use the code below so as to create a frame source string
dynamically. The idea is to verify if this index page is the parent or if it
called by an orphan page, in which case the orphan page passes its own name
as an argument to the index page.
Unfortunately, the code below returns an unspecified error.
This code is what is intended to create the index.htm page as it opens.

<HTML><TITLE>....</TITLE>

<SCRIPT type="text/javascript">
function window.onload()
{
checklocation();
}
function writetop()
{
document.body.insertAdjacentHTML('beforeEnd','<FRA MESET cols=20%,*
FRAMEBORDER="1" BORDER="1" scrolling=auto>')
document.body.insertAdjacentHTML('beforeEnd','<nof rames>')
document.body.insertAdjacentHTML('beforeEnd','</noframes>')
}
function writebottom()
{
document.body.insertAdjacentHTML('beforeEnd','</FRAMESET>')
document.body.insertAdjacentHTML('beforeEnd','</HTML>')
}
function checklocation()
{
//alert(top.location.href.length);
var theData;
var begin;
begin = top.location.href.indexOf("?");
if (begin > 0 )
{
theData = top.location.href.substring(begin+1,location.href. length);
theData = unescape(theData);
writetop();
document.body.insertAdjacentHTML('beforeEnd','<FRA ME name=main
src="files/ + theData + ">')
}
else{
writetop();
document.body.insertAdjacentHTML('beforeEnd','<FRA ME name=main
src="files/Help.htm">')
}
writebottom();
}
</script>
<body>

</body>
</html>
TIA
Phil
http://uk.geocities.com/philippeoget/a2z/
Jul 23 '05 #1
3 5658
Here is perhaps a simplier way to accomplish your goals:

<HTML><TITLE>....</TITLE>

<SCRIPT type="text/javascript">
//alert(top.location.href.length);
var theData;
var begin;
var url = "files/Help.htm";
begin = top.location.href.indexOf("?");
if (begin > 0 )
{
theData = top.location.href.substring(begin+1,location.href. length);
theData = unescape(theData);
url = "files/ + theData;
}
</script>
<FRAMESET cols="20%,*" FRAMEBORDER="1" BORDER="1" scrolling="auto">
<script type="text/javascript">
document.write("<FRAME name=main src='"+ url+"'>";
</script>
</FRAMESET>
</html>
One thing to notice is that you are missing a FRAME definition. I don't know
if that is intentional or not but perhaps that is the reason for your error
because you specify 2 frames in your frameset (cols="20%,*) but then only
define one.


Jul 23 '05 #2

The missing frame reference was unintentional but is present in the
'real' frameset.
In regard to your code: simple and graceful are 2 words that come to
mind.

Many thanks

Philippe
http://uk.geocities.com/philippeoget/
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Mike wrote:
Here is perhaps a simplier way to accomplish your goals:

<HTML><TITLE>....</TITLE>

<SCRIPT type="text/javascript">
//alert(top.location.href.length);
var theData;
var begin;
var url = "files/Help.htm";
begin = top.location.href.indexOf("?");
if (begin > 0 )
{
theData = top.location.href.substring(begin+1,location.href. length);
theData = unescape(theData);
url = "files/ + theData;
}
</script>


You are missing quotes after "files/
Even simpler below?
<SCRIPT type="text/javascript">
var url = "files/Help.htm";
if (top.location.search ){
url = "files/" + unescape(top.location.search.substring(1))
}
</script>

Mick
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by JesusFreak | last post: by
8 posts views Thread by Jeff Thies | last post: by
2 posts views Thread by sveinn | last post: by
1 post views Thread by Dmitry Kulinich | last post: by
4 posts views Thread by VAXman- | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.