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 07-13-2012, 06:46 AM   PM User | #1
ryanhx64
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ryanhx64 is an unknown quantity at this point
Need Help -.-

Ok i have this script it opens desired page then closes at desired amount of time. How do i make it redirect to something rather than google.com when closing? >.<


<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Test Page</title>
<style>
body {
font-family: sans-serif;
}
</style>
</head>
<body>
<p><a href="#" id="target">Start Earning Points</a>; You will will <b>1</b> point per <b>1</b> view.</p>
<script>
(function() {
document.getElementById("target").onclick = function() {
var wnd = window.open("http://google.com");
setTimeout(function() {
wnd.close();
}, 15000);
return false;
};
})();
</script>
<script src="/js/render/edit.js"></script>
<script>var _gaq=[['_setAccount','UA-1656750-13'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)})(document,'script')</script></body>
</html>
ryanhx64 is offline   Reply With Quote
Old 07-13-2012, 07:38 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
var wnd = window.open("http://google.com");

Just change the url to the url you require!

Or to redirect after the 15 seconds are up:-

setTimeout(function() {
wnd.close();
window.location = "http://www.javascriptkit.com";
}, 15000);
return false;
};
})();


Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 07-13-2012 at 07:44 AM..
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
coding, html, javascript

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 06:10 AM.


Advertisement
Log in to turn off these ads.