Results 1 to 3 of 3

Thread: Using javascript to write a script tag ?

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Using javascript to write a script tag ?

    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

    Code:
    	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 ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yep you've confused me But this line is wrong:

    Code:
    parent.main.write('document.write('alert("testing")');
    it should be something like this:

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

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    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).
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width