JavaScript Help
2 posters
Page 1 of 1
JavaScript Help
So I'm trying to make a script where anyone who is on a certain page on the site, it'll automatically be redirected to another page. For some reason, it's not working...
I have it checked to show on all pages.
Here's my code:
I have it checked to show on all pages.
Here's my code:
- Code:
$(function(){
$('a[href="http://aresiiocorpforums.forumotion.com/u3"]').not(function(){return $("img",this)[0]}).html('<script>window.location = "http://aresiiocorpforums.forumotion.com/profile?mode=viewprofile&u";</script>');
});
Re: JavaScript Help
Hello ThePhantomHourglass,
You can use the location object to change the pathname or entire URL.
Pathname :
Result :
User will be redirected to a custom HTML page
Entire URL :
Result :
User will be redirected to an HTML page, or another page you chose
You can also set a condition for the redirection :
Result :
If the users pathname is equal to /forum they will be redirected to an HTML page.
You can use the location object to change the pathname or entire URL.
Pathname :
- Code:
location.pathname = '/h1-';
Result :
User will be redirected to a custom HTML page
Entire URL :
- Code:
location.href = 'http://myforum.forumotion.com/h1-';
Result :
User will be redirected to an HTML page, or another page you chose
You can also set a condition for the redirection :
- Code:
if (location.pathname == '/forum') {
location.pathname = '/h1-';
}
Result :
If the users pathname is equal to /forum they will be redirected to an HTML page.
Re: JavaScript Help
I tried using the condition one. It doesn't seem to be working. Here's my code now:Ange Tuteur wrote:Hello ThePhantomHourglass,
You can use the location object to change the pathname or entire URL.
Pathname :
- Code:
location.pathname = '/h1-';
Result :
User will be redirected to a custom HTML page
Entire URL :
- Code:
location.href = 'http://myforum.forumotion.com/h1-';
Result :
User will be redirected to an HTML page, or another page you chose
You can also set a condition for the redirection :
- Code:
if (location.pathname == '/forum') {
location.pathname = '/h1-';
}
Result :
If the users pathname is equal to /forum they will be redirected to an HTML page.
- Code:
$(function(){
$('a[href="http://aresiiocorpforums.forumotion.com/u3"]').not(function(){return $("img",this)[0]}).html('<script>if (location.pathname == '/u3') {
location.pathname = '/h2-';
}";</script>');
});
Re: JavaScript Help
Where do you want to place it ?
If you want to place it on a profil you can do :
Administration panel > modules > javascript codes management > create a new script
Title : What you wish
Placement : in all the pages
Paste the code below and save :
Once done the user should be redirected while on u3's profile page.
If you want to place it on a profil you can do :
Administration panel > modules > javascript codes management > create a new script
Title : What you wish
Placement : in all the pages
Paste the code below and save :
- Code:
if (location.pathname == '/u3') {
location.pathname = '/h2-';
}
Once done the user should be redirected while on u3's profile page.
Re: JavaScript Help
Ahh, thank you. I fixed it. I didn't know I didn't have to put it in a function.Ange Tuteur wrote:Where do you want to place it ?
If you want to place it on a profil you can do :
Administration panel > modules > javascript codes management > create a new script
Title : What you wish
Placement : in all the pages
Paste the code below and save :
- Code:
if (location.pathname == '/u3') {
location.pathname = '/h2-';
}
Once done the user should be redirected while on u3's profile page.
You can archive and mark as complete/solved now.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum