JavaScript - Visitor Exit Url Redirect Script?
Friends,
I am looking for a PHP or Java Script to integrete in a PHP CMS, that enables to Redirect to Another URL when the script sense that the visitor is going away from the page. (Hit back button, hit refresh button and so on....) It should be unblockable by browsers. May anyone suggest me one or share the codes. I will use it for personal purpose and not for comercial purpose at all. Thanks Similar TutorialsHi, I want to take this redirect script and modify it so that it rotates a banner image instead of sending the user to another page. The script works so that if the window is out of focus for 10 seconds, it redirects. The images are defined in an external style sheet so I guess I'll have to move that into the document. Also, I want it to be able to work more than once with multiple images, like if the user opens a new tab, comes back, goes to a different tab, the image should change twice. Here's the script: Code: <script type="text/javascript"> var xScroll, yScroll, timerPoll, timerRedirect, timerClock; function initRedirect(){ if (typeof document.body.scrollTop != "undefined"){ //IE,NS7,Moz xScroll = document.body.scrollLeft; yScroll = document.body.scrollTop; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling timerRedirect = setInterval("location.href='http://www.google.com",10000); //set timed redirect } else if (typeof window.pageYOffset != "undefined"){ //other browsers that support pageYOffset/pageXOffset instead xScroll = window.pageXOffset; yScroll = window.pageYOffset; clearInterval(timerPoll); //stop polling scroll move clearInterval(timerRedirect); //stop timed redirect timerPoll = setInterval("pollActivity()",1); //poll scrolling timerRedirect = setInterval("location.href='http://www.google.com'",10000); //set timed redirect } //else do nothing } function pollActivity(){ if ((typeof document.body.scrollTop != "undefined" && (xScroll!=document.body.scrollLeft || yScroll!=document.body.scrollTop)) //IE/NS7/Moz || (typeof window.pageYOffset != "undefined" && (xScroll!=window.pageXOffset || yScroll!=window.pageYOffset))) { //other browsers initRedirect(); //reset polling scroll position } } document.onmousemove=initRedirect; document.onclick=initRedirect; document.onkeydown=initRedirect; window.onload=initRedirect; window.onresize=initRedirect; </script> The image is defined in Code: <div id="home" style="background: url(images/banner.png) no-repeat;"></div> I'm thinking I should replace banner.png with a variable or array name that has the image names defined somewhere and using a loop to choose the next image in the array. I took a C++ class but I don't know any JS, sorry for not doing homework. Thanks for reading this Hi there, Im very new to all this and have only been working with scripts for a few days, so simple pointers would be greatly appriciated. My problem; I play an online strategy game where i can use scripts to help my game play. There is a quick bar at the top of the game screen which i can add scripts to. When editing the bar there are 3 options. 1. Name, 2. Image URL, 3. Target URL. The script i have written is entered into the Target URL. It works fine but i have to be on a certain page in the game to run the script because of how it gets the required info. At the minute i have two scripts doing what i would like one to do. The first script (that i wrote) and a second which just redirects me to the right page (which i have to click first). Can i get both tasks on to one script. What i would like the script to do is, upon clicking redirect me to the appropriate page the script needs to be run from, and then run the javascript function. My Script; ( which isnt finished but works fine for now) Code: JavaScript: var n = prompt("1.Plunder / Looting 2. OD 3.Archer 4.Axe ", "1");n = parseInt(n); if(n == 1) {var stringOne = (document.getElementsByTagName("img")[12].title);var stringTwo = (document.getElementsByTagName("img")[10].title);var stringThree = (document.getElementsByTagName("img")[25].title);var stringFour = (document.getElementsByTagName("img")[24].title);var stringFive = stringOne + " \n" + stringTwo + " \nToday " + stringThree + " \nToday " + stringFour + "";alert (stringFive );}; if(n == 2) {var stringSix = (document.getElementsByTagName("img")[15].title);var stringSeven = (document.getElementsByTagName("img")[22].title);var stringEight = (document.getElementsByTagName("img")[23].title);var stringNine = stringSix + " \nToday as attacker " + stringSeven + " \nToday as defender " + stringEight + "";alert (stringNine );}; To sum up. Basicly i want to be able to click the link to this script and have it redirect me to the right page and then run. So where would i put the page address and how do i make the script rum when the page is loaded. Can anyone help me out with a script that can redirect based on IP address? I want all of my computers on my LAN, 192.168.1.1-255 to be redirected to a specific page. IE When I type in test.homeip.com it goes to my web server and reads the index.html file. If the IP is in the 192.168.1.0 range it will redirect to 192.168.1.10:80 and if its any other IP it will send it to 192.168.1.11:80 Thanks! Here is what I am looking to do. I want a user to click a link and auto log into a site and then start a certain citrix app. I am not a Java programmer so my skills in this error are limited. I did put a script together that is below but it is very sloppy. It passes the credentials and logs in to Citrix and auto starts the app but it has to have two pages open to do this. Is there not a way to have Java log into a site then pass it back to the original page so it can finish the script to auto start the app. Thanks for the help. Code: <html> <head> <title>Post Page</title> <SCRIPT LANGUAGE="JavaScript"> <!-- function loginCitrix(){ go1(); go2(); } function go1() { CitrixForm.submit(); } function go2() { setTimeout('document.location="http://ctx.server1.com/Citrix/XenApp/site/launcher.aspx?CTX_Application=Citrix.MPS.App.CitrixProd.Notepad&LaunchId=1301587978804"',3000) } //--> </SCRIPT> <body onLoad="loginCitrix();"> <form method="POST" action="http://ctx.server1.com/Citrix/XenApp/auth/login.aspx" name="CitrixForm" rel="nofollow" target="_blank"><br> <input type='hidden' name='user' value='username'><br> <input type='hidden' name='password' value='password'><br> <input type='hidden' name='domain' value='corpdc'><br> <input type='hidden' name='LoginType' value='Explicit'><br> </form> </body> </html> Hi, I am trying to implement a script which redirects visitors to one of 24 html pages based on the hour it is when they visit. I have tried a number of other script I could find and nothing even close to working has been achieved. The pages are named: 0.html, 1.html, 2.html.....up to....22.html & 23.html I already have a simple script in use for the day of the week and am sure there must be something similar I can do for the hour of day. Any help that can be offered will be greatly appreciated as this is driving me mad. Perhaps this wouldn't even be Javascript, but here's my question. Is there a script that would direct Opera users past the front page of a web site (that uses flash) to the home page? For instance, a site I'm building as a favor to a church has a flash intro page that is fine with every browser but Opera. (Opera doesn't respond to Autoplay but places a large "Play" button where the flash is located.) On this particular page, the flash movie ends with an "Enter" instruction and is a hyperlink to the "home" page, so if an Opera user clicks that button, they're still not going to see the flash but are going to arrive at the "home" page. Is there a way to not even present them with the flash page, but to send them straight to the home page? I'd appreciate any assistance. Hi, I am pretty much a noob when it comes to javascript. I am looking for a script that redirects random.html to 1 of 86 predefined pages, randomly. If someone could help me out, that would be great. Thanks for your help Hi, Please i am not getting clear understanding of a javascript code to redirect user to a different web page based on the day of the week. Please i have search for many script and not getting clear understanding from their code.I have also try several code myself but nothing good has come from it. Please can someone help me and write a descriptive code for me to understand better.I really plead you and your to help me...but i belief the Lord God will bless you for your time helping me. looking forward to here from you. Thank you. Clement Osei I'm currently working on a site with an exit pop asking the visitor, "Are you sure you want to leave?" The problem is that one of the links in the page is triggering the exit pop when it shouldn't be. Here's the code: Code: <a href="intended_next_page.html" class="style4" onClick="ShowExitPopup = false;">Click Here To Continue </a> I know this itself is HTML, but it's related to the exit pop, which is Javascript, so I thought this forum would be the appropriate one. Any idea why this isn't working? I have another link on the page that looks identical (goes to a different page, but that's it), and it's working, but this one isn't. I can't figure it out. Any help is greatly appreciated. I re-wrote this code to display an exit notice alert and open a new window after user confirms they wish to leave the website. However, something is wrong with my code below. The alert and cancel alert works fine, but my new window link does not appear. I was curious if i could get some help fixing this code from anyone in the JavaScript programming forum. See code: <script language='JavaScript'> function ExitNotice() { if(confirm("You are now leaving the web site. To leave our site for the link you selected, click OK. Or Click Cancel to remain. Thank you for visiting our site.")) { return true; } history.go(0); return false; } </script> Now for my button code that appears later inside my form which opens a sized window. <input id="btnView" class="MyButton" type="button" onclick="ExitNotice('http://www.google.com', null, 'left=40,top=100,height=550,width=780, status=no,toolbar=no,menubar=no,location=no, resizable=yes, scrollbars=yes')" name="btnView" value="View Web Site" /> Please test and advise what i'm missing... thanks in advance as i eagerly wait for a solution that fixes this issue. Hello, I'll be honest I dont know much about javascript so hopefully one of you lovely people can help. My issue is I would like to have this code validate my radio buttons on my form and also have an onscreen pop-up in the case that the user is exiting the page without filling out the form. I have had both of these peices of code working...but when I put both of them on the page the pop-up will override the validation script, and I don't wish to have the pop-up, pop-up when the user hits the submit button. Here are my pieces of code: Inside my head tag: Code: <script language="JavaScript"> function closeIt() { return "\n********************************************\nWAIT! WAIT! WAIT! WAIT! WAIT! WAIT!\n********************************************\n\nDon't leave just yet...\n\nDon't worry - We will never rent, sell or\nshare your contact information, with\nanyone else. We respect your privacy\nand hate spam too!\n\n"; } window.onbeforeunload = closeIt; </script> <script language="JavaScript"> function valbutton(thisform) { // place any other field validations that you require here // validate myradiobuttons myOption = -1; for (i=thisform.infusion_option_0.length-1; i > -1; i--) { if (thisform.infusion_option_0[i].checked) { myOption = i; i = -1; } } if (myOption == -1) { alert("You must select an event city date"); return false; } // place any other field validations that you require here thisform.submit(); // this line submits the form after validation } </script> And then for my form and submit code I have: Code: <form name="myform" action="https://mydomain.com/AddForms/processFormSecure.jsp" method='POST' onSubmit="return NoneWithCheck();"> <input id="Submit" name="Submit" type="submit" value="Submit" onClick="valbutton(myform);return false;" /></form> Any help would be appreciated, thanks. I was advised by a community member this post would be better suited for the JavaScript section (hope someone can help): The exit pop-up script I have is working fine, other than the fact that it engages on any internal links as well. Below I have the original script I was using along with a modified script sent back to me from someone in another forum. They also advised me to add rel="external" to all of my external links. I'm not sure if a different condition would apply whether the link stayed within my site or went elsewhere. In any event, it's still not working. The changes get me to my desired page on internal links, but the pop-up still engages and I have to click "OK" before it takes me there. I'm obviously looking to get this to work so that all internal links go straight to the page they're defined to, without the pop-up engaging at all. Both script versions are below: My original: Code: <script type="text/javascript"> var internal = 0; function bunload() { if (internal != 1) { window.onbeforeunload = null; alert("******************************************************\n WAIT! WAIT! WAIT! WAIT! WAIT! WAIT!! WAIT!!\n******************************************************\n\nMy partner will probably KICK MY *** for this...\n\nI am secretly giving away a LIMITED number of $20\ncoupons just for Tweeting about us.\n\nIf you act right now, you can grab our Manuscript\nplus ALL Bonuses for just $27!\n\nJust click *CANCEL* on the next window to get your\nV.I.P. discount link!\n\n******************************************************"); window.location = "gift page"; return "******************************************************\n Click CANCEL - Click CANCEL - Click CANCEL \n******************************************************\n\n Click *CANCEL* Now to get your V.I.P. discount!\n\n"; } else { internal = 0; } } if (internal != 1) { window.onbeforeunload = bunload; } else { internal = 0; } </script> And the modified script another community member replied back to use: Code: <script type="text/javascript"> var internal = 0; function bunload() { if (internal != 1) { window.onbeforeunload = null; alert("******************************************************\n WAIT! WAIT! WAIT! WAIT! WAIT! WAIT!! WAIT!!\n******************************************************\n\nMy partner will probably KICK MY *** for this...\n\nI am secretly giving away a LIMITED number of $20\ncoupons just for Tweeting about us.\n\nIf you act right now, you can grab our Manuscript\nplus ALL Bonuses for just $27!\n\nJust click *CANCEL* on the next window to get your\nV.I.P. discount link!\n\n******************************************************"); window.location = "gift page"; return "******************************************************\n Click CANCEL - Click CANCEL - Click CANCEL \n******************************************************\n\n Click *CANCEL* Now to get your V.I.P. discount!\n\n"; } else { internal = 0; } } if (internal != 1) { window.onbeforeunload = bunload; } else { internal = 0; } window.onload = function() { var links = document.getElementsByTagName('a'); for(i = 0 ; i < links.length; i++) { if(links[i].getAttribute('rel') == 'external') { links[i].onclick = function() { bunload(); } } } } </script> Any suggestions on what I'm doing wrong here? My apologies, but my coding isn't very strong and I'm just picking this stuff up as I go. Thanks Hello, Our website is built in ASP.NET and uses a content management system. The CMS came with a wealth of JavaScript files and I decided to use one of these files for form validation. Although the file is over 2,300 lines, from what I can tell it is supposed to return true if the form is valid and false otherwise. The problem is that a function inside that file seems to get to a certain point, and somehow quit and return true no matter if the form is valid or not. I am calling this JS from an ASP.NET button control. When the button is clicked, a JS function ValidateForm(document.forms[0]) is called. My ValidateForm function calls another function inside the JS file (which calls another, and another...). No matter what, when that second function is called and executed, code execution stops at some point and the form submits (postbacks). I can see that the validation is working just before the postback, but it is not preventing the form from being submitted, and it also stops executing any code after it. Here is my code: ASP: Code: <asp:Button ID="SubmitBtn" runat="server" Text="Submit Form" CausesValidation="false" CssClass="submit_button" OnClientClick="FmValidate(document.forms[0]); return false;" OnClick="SubmitBtn_Click" /> My Javascript: Code: function FmValidate(formObj) { var strError = ''; var e = null; if (strError == '' && 'function' == typeof design_validateHtmlForm) { alert('before'); // this line causes execution to stop - located in external JS file // code states "Returns first invalid element, or null." e = design_validateHtmlForm(formObj); alert("e is " + e); if (e) { strError = e.title; } return false; } } In my ASP.NET button, changing the OnClientClick method to "return false" will prevent form submission, but "return FmValidate(formObj);" will not if that function calls design_validateHtmlForm(formObj). I receive the message box saying "before" but I never receive the second one. I have debugged using Fire bug, but the code seems to cycle through each element on the page and stepping through the code is not realistic (I have done so for 20-minute stretches). I am wondering if anyone has any ideas what code I could look for that would stop execution and return true no matter what, or how I could begin debugging this monster. Hey guys, I'm trying to accomplish something similar to what the develop on this site did: http://backlinkwatch.com/ When you click on the text area, a clickable image, with a 50% black opacity background overlay, and an exit either through a link or clicking outside of the box, shows up. I want to accomplish the same thing, but have the image popup show up on the page load instead of requiring a click of the text area. In addition, I would like this popup only once to each IP address; ie, if you visit a page on my site, this will show up, but if you close it and refresh the page or visit another page on the site a cookie will be stored that knows its already been opened once and it won't try to do it again. Thanks to anyone who can help me with this! Hi everyone! I'm trying to make this code run and keep getting the same error. "Could not find the main class: Initials. Program will exit." I'm using jcreator and java is up to date. I really not sure if I posted this in the correct area but any pointer will help. I'm a noob at this so thank you anyone who takes the time out to help me. Thanks in advance code i setup: public class Initials { public static void main(String[] args){ } { System.out.println("JJJJJJ FFFFFF"); System.out.println(" J F"); System.out.prinlLn(" J FFFFF"); System.out.println(" J F"); System.out.println(" J J F"); System.out.println(" JJJJJJ F"); } } Errors: --------------------Configuration: Initials - JDK version 1.6.0_21 <Default> - <Default>-------------------- java.lang.NoClassDefFoundError: Initials Caused by: java.lang.ClassNotFoundException: Initials at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: Initials. Program will exit. Exception in thread "main" Process completed. Hi all new guy on the block here, I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference) I think i nutted something out in a bit of PHP, this is what i've got so far PHP Code: <?php if (firstLogin()){ genSpecial(***load jquerie or css etc***); } else{ genRegular(); } ?> can anyone help me figure out how to make this all work and load a box from jquerie or something similar? thanks David First off, I'm working with tumblr.com which allows Javascript, but not PHP embedded in the HTML pages. It strips them out. I want to be able to get the country code (us, ca, uk, etc.) when a visitor visits my webpage so I can provide links for their locale. I'm having a very hard time finding correct information with examples to get this working. There was some .js libraries out there, but they don't work properly and say I'm in CA when I'm in US, like the jsapi from Google. Is there a way to execute a .php script which would output the country code of the visitor and be able to read/capture this result within the Javascript? Thanks in advance. Edward Hello, I was wanting a message to be displayed if it is the visitors first time to the site. It will be a toolbar displayed at the top of the website, with links to FAQ's. Any method of display this is fine. Thanks Hello, I have recently started a website which tells visitor's IP address, location and others details. I want to add some more functions to it. I found no way to detect visitors Internet Service Provider (ISP) using PHP. I would like to know if there is any way to do so in Javascript. Click the below link to view the site: Show IP Please help me ASAP. Regards, Wasif K. Hello everyone. I have a a html page that is used as a login page. I know it is not secure but this is just for learning purposes, I'm not using it for anything important. My problem is that when I put in the correct login all that happens is the page just clears the text boxes as if you were starting over. I am trying to get it to go to register.html which is located in the same directory as the login page. Help with what I'm doing wrong would be greatly appreciated. Here is the code: Code: <html> <head> <title>Login Page</title> </head> <body> <script type = "text/javascript"> var count = 2; function validate() { var un = document.myform.username.value; var pw = document.myform.pword.value; var valid = false; var unArray = ["Philip", "George", "Sarah", "Michael"]; // as many as you like - no comma after final entry var pwArray = ["Password1", "Password2", "Password3", "Password4"]; // the corresponding passwords; for (var i=0; i <unArray.length; i++) { if ((un == unArray[i]) && (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("Login was successful"); window.location = "register.html"; return false; } var t = " tries"; if (count == 1) {t = " try"} if (count >= 1) { alert ("Invalid username and/or password. You have " + count + t + " left."); document.myform.username.value = ""; document.myform.pword.value = ""; setTimeout("document.myform.username.focus()", 25); setTimeout("document.myform.username.select()", 25); count --; } else { alert ("Still incorrect! You have no more tries left!"); document.myform.username.value = "No more tries allowed!"; document.myform.pword.value = ""; document.myform.username.disabled = true; document.myform.pword.disabled = true; return false; } } </script> <form> <table border ="5"> <tr> <th colspan="2">Login</th> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pword" /></td> </tr> <tr> <th colspan="2"><input type="Submit" value="Login" name="Submit" onClick="validate()" /><input type="Reset" value="Reset" /></th> </tr> </table> <p> <a href="register.html">New users click here to register</a> </p> </form></body></html> |