PDA

Click to See Complete Forum and Search --> : Using javascript to write a script tag ?


plenderj
Nov 25th, 2002, 06:09 AM
I'm trying to write a <script> tag with a script inside it, from another script.
But I can't seem to get it to work.

This is what I have at the moment


function redirectFrame() {

parent.main.write('<script language="JavaScript">');
parent.main.write('document.write('alert("testing")');
parent.main.write('</script>');

}



Basically, the reason for all this is that our other branch has a website, and im going to ask them to link to a particular page.
Now that page itself is a frameset, and once the page has loaded a piece of JS makes the bottom page navigate to another page.

The problem with that approach was that the piece of javascript, which I have in the frameset page itself, was executing each time the user has browesed to a new page, and then it would make them go back to a different page.
So I was thinking I would have to put a piece of JS into the created page myself.

... so um yeah.
I think I've probably confused anyone reading ?

Rick Bull
Nov 25th, 2002, 12:05 PM
Yep you've confused me :D But this line is wrong:


parent.main.write('document.write('alert("testing")');


it should be something like this:


parent.main.document.write('document.write(\\'alert("testing")\\')');

techgnome
Nov 25th, 2002, 12:39 PM
The other thing you can do is detect if the user is in the frameset or not. Try http://www.dynamicdrive.com I think you might find it there.
Then once you detect if you are in the frameset or not, you can change the bottom frame (or not).