Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Redirect a HTML page using external JS file

    Hello,

    I am in situation where I need a code to redirect a HTML page to new location (Static HTML/Dynamic Web page) however the challenge is that I can not use usual JavaScript Redirect code due to restriction that we can't execute any code/script under body tag.

    I found that this can be done using an external JS file however I am not able to achieve this.

    I need the code to be generic so we can apply the same JS file to any page. However, I want the new window to open over the previous one versus opening a second new window.

    Can someone help me out in this?

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,335
    Thanks
    13
    Thanked 348 Times in 344 Posts
    why not using <meta http-equiv="refresh" content="5; URL=http://www.example.org/">?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your reply, however as I mentioned before, I can't add any code/script withing Body, HTML tags.

  • #4
    d_s
    d_s is offline
    New Coder
    Join Date
    Mar 2010
    Location
    India
    Posts
    52
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Smile Redirect a HTML page using external JS file

    Hi,

    Hope your query is about the page redirection using an external javascript file.
    For this reason, the following code can be placed in a separate file and then called in your page's head section.

    It causes redirection in a new page.

    hope this code does satisfy your intended purpose.

    Code:
    var wnd = window.open("http://www.google.com","_blank","true");
    you may find more details on this arguments on my blog at : http://dsaravanan.wordpress.com/

    Regards,

    d_s

  • #5
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @ D_S,

    This sound interesting. Do we have any working example. if yes plz share so that I can try for it.

  • #6
    d_s
    d_s is offline
    New Coder
    Join Date
    Mar 2010
    Location
    India
    Posts
    52
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Smile Redirect a HTML page using external JS file - Source Code - Reg

    Hi,

    I do have the source code, here is the source code for the HTML Page

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script language="javascript" type="text/javascript" src="JScript.js">
        </script>
    </head>
    <body>
    <h2>Welcome to Auto Page Redirection </h2>
    </body>
    </html>
    Here is the sript file for "JScript.js"
    Code:
    var wnd = window.open("http://www.google.com","_blank","true");
    Hope this helps you..

    regards,

    d_s.

  • #7
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks D_J, it worked as I intended.


  •  

    Tags for this Thread

    Posting Permissions

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