Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-08-2010, 04:54 AM   PM User | #1
reachaddy
New to the CF scene

 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
reachaddy is an unknown quantity at this point
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?
reachaddy is offline   Reply With Quote
Old 03-08-2010, 05:57 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,855
Thanks: 9
Thanked 288 Times in 284 Posts
Dormilich is on a distinguished road
why not using <meta http-equiv="refresh" content="5; URL=http://www.example.org/">?
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 03-08-2010, 06:01 AM   PM User | #3
reachaddy
New to the CF scene

 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
reachaddy is an unknown quantity at this point
Thank you for your reply, however as I mentioned before, I can't add any code/script withing Body, HTML tags.
reachaddy is offline   Reply With Quote
Old 03-08-2010, 06:03 AM   PM User | #4
d_s
New Coder

 
Join Date: Mar 2010
Location: India
Posts: 52
Thanks: 0
Thanked 8 Times in 8 Posts
d_s has a little shameless behaviour in the past
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
d_s is offline   Reply With Quote
Old 03-08-2010, 06:16 AM   PM User | #5
reachaddy
New to the CF scene

 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
reachaddy is an unknown quantity at this point
@ D_S,

This sound interesting. Do we have any working example. if yes plz share so that I can try for it.
reachaddy is offline   Reply With Quote
Old 03-08-2010, 07:10 AM   PM User | #6
d_s
New Coder

 
Join Date: Mar 2010
Location: India
Posts: 52
Thanks: 0
Thanked 8 Times in 8 Posts
d_s has a little shameless behaviour in the past
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.
d_s is offline   Reply With Quote
Old 03-09-2010, 03:30 AM   PM User | #7
reachaddy
New to the CF scene

 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
reachaddy is an unknown quantity at this point
Thumbs up

Thanks D_J, it worked as I intended.
reachaddy is offline   Reply With Quote
Reply

Bookmarks

Tags
external js, redirect

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 AM.


Advertisement
Log in to turn off these ads.