redirecting script problem
3 posters
Page 1 of 1
redirecting script problem
ehm
Hi all
i was using a code to redirect post links in a good way actually
like
u'll be redirected to the link in 5 secs and here's the code
and here's the java code for it
so the problem is
the code opens the post link in the same page
i was wondering if there's anyways to make it opens in a new window ?
Hi all
i was using a code to redirect post links in a good way actually
like
u'll be redirected to the link in 5 secs and here's the code
and here's the java code for it
- Code:
$(function () {
$(".post-entry a").not("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif'],a[href$='.bmp'],a[href^='/'],a[href^='" + location.origin + "']").click(function (a) {
a.preventDefault();
a = location.href;
var b = this.href;
z = "/redirect/?url=" + encodeURIComponent(b);
window.history && history.pushState ? history.pushState({}, "Redirecting...", z) : location.hash = z;
var d, c = 5;
$("#main-content").html('<div id="redirects"><h3>Redirecting...</h3><p class="redirectMess">You are preparing to leave <strong>' +
document.title + '</strong>and move to the path: <strong><a href="' + b + '" rel="nofollow">' + b + '</a></strong>within <strong><span class="delayTime">' + c + '</span></strong>more seconds ... You want to make sure that this path is not?</p><div class="redirectFooter"><ul class="redirectButtons"><li><a class="cancel" href="' + a + '">back</a></li><li><a href="' + b + '" class="redirectSkip forward" rel="nofollow">continue (<span class="delayTime">' +
c + "</span>)</a></li></ul></div></div>");
d = setInterval(function () {
var a = c--;
0 > a ? window.location = b : $(".delayTime").text(a)
}, 1E3);
$(".redirectButtons a").click(function () {
clearInterval(d)
})
})
});
so the problem is
the code opens the post link in the same page
i was wondering if there's anyways to make it opens in a new window ?
Last edited by neos on July 19th 2016, 11:00 am; edited 1 time in total
Re: redirecting script problem
Hi
Try replacing
with
. If that doesn't work, you can make a redirect anchor with target="_blank" and force click it with javascript. Here is an example:
Try replacing
|
|
- Code:
var a = $('<a href="http://help.forumotion.com/u94304" target="_blank" />')[0];
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Re: redirecting script problem
awrighty
the first method did opened it in a new window
but the direction thingy didn't appear actually
here's the things
this code suppose to have this redirection page if someone clicked on the external links
and it's opening in the same page
and when i tried ur method #1
it opened in a new window but that redirecting page didn't appear
so about your method #2
i actually didn't frankly get it
0.0
can u please clarify it a little ?
thanks in advance
the first method did opened it in a new window
but the direction thingy didn't appear actually
here's the things
this code suppose to have this redirection page if someone clicked on the external links
and it's opening in the same page
and when i tried ur method #1
it opened in a new window but that redirecting page didn't appear
so about your method #2
i actually didn't frankly get it
0.0
can u please clarify it a little ?
thanks in advance
Re: redirecting script problem
oooo I'm sorry, I misread your script! It should have been
.
The second method creates a link and clicks it. It works about the same as window.open.
|
The second method creates a link and clicks it. It works about the same as window.open.
Re: redirecting script problem
How about this?
- Code:
$(function () {
$(".post-entry a").not("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif'],a[href$='.bmp'],a[href^='/'],a[href^='" + location.origin + "']").click(function (a) {
a.preventDefault();
a = location.href;
var b = this.href;
z = "/redirect/?url=" + encodeURIComponent(b);
window.history && history.pushState ? history.pushState({}, "Redirecting...", z) : location.hash = z;
var d, c = 5;
$("#main-content").html('<div id="redirects"><h3>Redirecting...</h3><p class="redirectMess">You are preparing to leave <strong>' +
document.title + '</strong>and move to the path: <strong><a href="' + b + '" rel="nofollow">' + b + '</a></strong>within <strong><span class="delayTime">' + c + '</span></strong>more seconds ... You want to make sure that this path is not?</p><div class="redirectFooter"><ul class="redirectButtons"><li><a class="cancel" href="' + a + '">back</a></li><li><a href="' + b + '" class="redirectSkip forward" rel="nofollow" target="_blank">continue (<span class="delayTime">' +
c + "</span>)</a></li></ul></div></div>");
d = setInterval(function () {
var a = c--;
0 > a ? $('.redirectSkip')[0].click() : $(".delayTime").text(a)
}, 1E3);
$(".redirectButtons a").click(function () {
clearInterval(d)
})
})
});
Re: redirecting script problem
It opens in a new tab for me but you have to allow popups.. I can't think of anything else. These are all the things that open in new windows that I can find:
window.open - https://developer.mozilla.org/en-US/docs/Web/API/Window/open
target (attr for anchor) - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target
For what you are doing, I think it would probably be best if the user chose to continue or go back instead of being redirected automatically.
window.open - https://developer.mozilla.org/en-US/docs/Web/API/Window/open
target (attr for anchor) - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target
For what you are doing, I think it would probably be best if the user chose to continue or go back instead of being redirected automatically.
Re: redirecting script problem
okay bro
thanks alot for helping out
^_^
i decided to abandon the whole code
thanks again
thanks alot for helping out
^_^
i decided to abandon the whole code
thanks again
Re: redirecting script problem
Problem solved & topic archived.
|
Similar topics
» Redirecting Problem
» Reputation (Like) script problem
» External Domain Redirecting Problem
» Watermark script problem
» Script problem
» Reputation (Like) script problem
» External Domain Redirecting Problem
» Watermark script problem
» Script problem
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum