redirecting script problem
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
neos- Forumember
- Posts : 36
Reputation : 1
Language : Englsh
Location : Egypt
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);
An- Forumember
- Posts : 44
Reputation : 24
Language : English
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
neos- Forumember
- Posts : 36
Reputation : 1
Language : Englsh
Location : Egypt
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.
An- Forumember
- Posts : 44
Reputation : 24
Language : English
Re: redirecting script problem
tried it
still opens in the same window o.o
still opens in the same window o.o
neos- Forumember
- Posts : 36
Reputation : 1
Language : Englsh
Location : Egypt
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)
})
})
});
An- Forumember
- Posts : 44
Reputation : 24
Language : English
Re: redirecting script problem
i've tried this too bro
but still opens in the same page
but still opens in the same page


neos- Forumember
- Posts : 36
Reputation : 1
Language : Englsh
Location : Egypt
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.
An- Forumember
- Posts : 44
Reputation : 24
Language : English
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
neos- Forumember
- Posts : 36
Reputation : 1
Language : Englsh
Location : Egypt
Re: redirecting script problem
Problem solved & topic archived.
|
Ape- Administrator
-
Posts : 16238
Reputation : 1751
Language : fluent in dork / mumbojumbo & English haha
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum