Javascript stopping redirect

Good Early Morning (just barely) I have an issue with a javascript function in portion of a script apparently sending something to the browser that is preventing a redirect from working the way it was before I added this JS... Here is the JS that I added $(function() { var dates = $( "#from, #to" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 1, onSelect: function( selectedDate ) { var option = == "from" "minDate" : "maxDate", instance = $( this ).data( "datepicker" ), date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings ); dates.not( this ).datepicker( "option", option, date ); } }); });
After that the tag comes, and then the body and a display table, etc... of this was working just fine... In the table there is a comparison of a variable like this: if ($accept != 'Y'){ // variable set in logcheck header('Location:../memupdate.php');// if haven't accepted TOS go there exit; }
Before the JS code, when $accept wasn't 'Y' then it redirected just fine...
With the JS code, it ignores the redirect and just exits... What is it in the JS code that would be interpreted as sending something to the browser, which is the only thing I can figure would be happening I know it is in that section of js code because if I take that out of the section, the script goes back to working just fine... Any assistance in this matter would be greatly appreciated. Douglas OK, I've narrowed it down even further...
If I take out this portion of the code, then it allows the page to redirect as it should onSelect: function( selectedDate ) { var option = == "from" "minDate" : "maxDate", instance = $( this ).data( "datepicker" ), date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings ); dates.not( this ).datepicker( "option", option, date ); }
So what is it in that code that would cause the problem Any ideas

Posted On: Sunday 25th of November 2012 08:39:26 PM Total Views:  508
View Complete with Replies

Related Messages:

this forum refresh is stopping my refreshcontainer from refreshing   (186 Views)
hi , i have a forum system that auto refreshes, but what that is doing is stopping my refresh container from refreshing to let people know if they have new inbox messages, im not very good with javascript and i cant figure out why its doing it. any help would be great, below are both of my codes. Forum refresh: Code: function keepRefreshed(){ if(set == 0){ refresher = setTimeout("keepRefreshed()", 60000); allowButton = setTimeout("allowRefresh()", 3000); set = 1; } else { refreshTopics(); } } function allowRefresh(){ document.replyForm.refreshButton.disabled = false; } function refreshTopics(hl){ if(set == 1){ clearTimeout(refresher); clearTimeout(allowButton); } document.replyForm.refreshButton.disabled = false; refresher = setTimeout("keepRefreshed()", 60000); allowButton = setTimeout("allowRefresh()", 3000); Refresh container: Code: $(window).ready(function() { $("#responsecontainer").load("includes/inc-mess-jail.php", function(response, status, xhr) { if (status == "error") { $(this).html("Error: " + xhr.status + " " + xhr.statusText); } }); var refreshId = setInterval(function() { $("#responsecontainer").load('includes/inc-mess-jail.phprandval='+ Math.random()); }, 9000); $.ajaxSetup({ cache: false }); }); as i said, any help would be great.
Default event not stopping even with return false;   (360 Views)
I am having trouble with some JavaScript that is supposed to add some Google Analytics tracking parameters to "cross-domain" links (used to auto append tracking info across multiple domains as a way of sharing the Google cookie info). I have my code kind of working at this point except the default event (the normal href link) is not stopping. Instead my new event (the link plus Google parameters) fires off and is immediately replaced by the default (no parameters) event. For links that open in a new window, two windows open, one the standard link and one with the intended parameters. I am using a return false; on each link type but it is not doing anything. Any ideas how I can stop the default event Code: Code: //Last Updated 5/10/12 /*Regex list of on-site domains, pipe and backslash delimited. */ var wa_onsiteDomains = /mydomain\.com|my2nddomain\.com|my3rddomain\.com|javascript/i; /*Used to unobtrusivly add events to objects*/ function unobtrusiveAddEvent (element,event,fn) { var old = (element[event]) element[event] : function () {}; element[event] = function () {fn(); old();}; } function wa_crossDomainLink(i) { return function () { var thisLink = decodeURI(wa_links[i]); var thisLinkTarget = wa_links[i].target; if (typeof(_gaq) == "object") { if(thisLinkTarget == "_blank") { var wa_myTracker=_gat._getTrackerByName(); var wa_fullUrl = wa_myTracker._getLinkerUrl(thisLink);; return false; } else { _gaq.push(['_link', thisLink]); return false; } } }; } var wa_links = document.links; if ( wa_links ){ for(var i=0; i
stopping a switch function?   (278 Views)
I have a switch function with four cases: each case executes a sequence of six css changes. How to stop it, if the viewer wants to abort, by choose another menu option I've done a trawl, and the closest I've come to finding something which could be adapted is from this site, by MattEvans, a while back, buit it had to do with a loop in the function to be stopped: [INDENT]create a public/global variable called "stopped", set it to false when you start the loop. inside the loop put: if(stopped){ break; } then when you press "cancel" set the stopped variable to true .[/INDENT] So, maybe something like var=stopped function wrapSwitch() { if(stopped){ break; } function doSwitch{ etc } } stop Any pointers Cheers., stop
Page is getting redirected when I close a Modal dialog?   (380 Views)
Sorry I forgot to mention the problem. The Page is getting redirected to the page opened in the modal dialog.
how do i redirect two pages back with javascript(not?   (271 Views)
Is my Javascript Codes stopping my browser from showing?   (225 Views)
The Javascript that I have included in my php created site is $(window).load(function(){ setHeight(); }); if(!= -1) { } else { window.onresize = function(){ setHeight(); } } Would this cause my browsers (Firefox - IE - Chrome - Opera) to not work
Javascript stopping navigation   (176 Views)
, I just 'launched' my own SNIP which is supposed to be an advanced online portfolio for artists and photographers. One of the main features is the continuous preloading of all the images so that the artwork enlargements are shown instantly. SNIP is my 'demo' and it seems to be working fined in Mozilla, with IE playing up horribly in one way: there is this lengthy Javascript function (I'm using the good old MM_preloadImages) preloading all the 200-odd photographs of the website. Every page of this website is calling this same function, as I reckoned it would, if the user browsed to another page, simply race through the images already in the cache and continue where it was interrupted. Heartbreakingly, it doesn't in IE - click on a menu item and it will simply wait until all the images have been loaded before moving on. Can anyone tell me how I can interrupt the execution of that function in IE
redirect if site is available   (274 Views)
hello, i have an online store and sometimes i have to close it for maintenance. when i close the store the visitors are redirected to a store_closed page where they read that the store "is temporarily closed for maintenance." i'm looking for a way to automatically redirect the visitors back to the main page once it's available again without having them to refresh the browser. is this feasible
OnBeforeUnload to redirect user   (353 Views)
In my onbeforeunload event, it asked the user whether they want to leave the page or stay on it. When they click "stay on page", I want it to then redirect them to another webpage in the same window. Is there a way to do this, without just showing/hiding divs Can I override the function
stopping page loading if error   (279 Views)
hi im checking for validation on my page but also trying to submit the data to another form but if theres an error if still loads onto the other page is there any way i can stop this to allow the user to fix the errors The Rail Line window.onload = function getTime() { var d = new Date(); var time = d.getHours(); if (time=12) { document.getElementById("welcome").innerHTML += "Good Afternoon and Welcome to The Rail Line!Your one stop shop for all your train travelling needs.Below you will find a form to use to order your tickets."; } var browser = navigator.appName.toLowerCase(); if(browser == 'microsoft internet explorer'){ document.getElementById('footer').className = 'iefooter'; } } function check_fields(form){ var error1 = 0, error2 = 0, error3 = 0, error4 = 0, error5 = 0, error6 = 0, error7 = 0, error8 = 0, error9 = 0, error10 = 0; if (form.Destination.value == '') error1 = 1; if (form.Date.value == '') error2 = 1; if (form.Date1.value == '') error3 = 1; if (form.Date2.value == '') error4 = 1; if (form.Time.value == '') error5 = 1; if (form.Time1.value == '') error6 = 1; if (form.Tnum.value == '') error7 = 1; if (form.Age.value == '') error8 = 1; if (form.Class.value == '') error9 = 1; if (error1==1 || error2==1 || error3==1 || error4==1 || error5==1 || error6==1 || error7==1 || error8==1 || error9==1 || error10==1 ){ alert('One or more boxes were empty - redo'); return (false) } var chosen = ""; len = document.form1.Ttype.length; for (i = 0; i
problems with redirect of page   (269 Views)
Use the line window.location = 'urlhere'; and put it wherever you need it to redirect the user like after the line alert('You have already registered! '+username+'!');. Of course replace "urlhere" with the actual URL you want them directed to. That should get things moving ... literally. Enjoy!
need help with auto redirect   (370 Views)
hi i have no idea about how to do that but if possible,can somebody give me a complete code of javascript that can allow mw to autoredirect to a page i want so i making a site in folder and i want the index.html o be the only one visible but if it was taken out of the folder , the links will not work so i want to make an empty site, it will be opened and automatically redirect to the index page as a sort of a shortcut cuz the shortcut won't work if it was put on a cd cansomebody please help me.i have no idea bout how to do it i am using frontpage in my site
Writing redirect cookie with checkbox   (278 Views)
I've got a website with a splash page where users select one of two languages in which to access the page, and have the option of ticking a "remember me" checkbox, which would write a cookie. On subsequent visits to the splash page, the cookie would be read, and the user would be instantly redirected to the appropriate language version of the site. I'm new to JS, and want to avoid building bad coding habits; what would be a recommended way of coding this
For loop help, redirect loader.   (264 Views)
I am working on a redirect script for a fancybox that loads a video, and then redirects the user to a new webpage when the fancybox is closed. I have the loader, and the redirect working. However every video that is loaded redirects to the same page. I believe this to be a loop issue, and I could use some help. // Jquery to load fancybox with iframes, and redirects var sponsors = [ {selector: ".video_one", uri: ""}, {selector: ".video_two", uri: ""} ]; $(document).ready(function(){ for(var i = 0; i < sponsors.length; i++) { var msg = sponsors[i].uri; var myDel = function(){window.location.replace(msg);} $(sponsors[i].selector).fancybox({ 'width' : '40%', 'height' : '60%', 'type' : 'iframe', 'closeBtn': false, 'afterClose': function(){myDel();} }); } });
Joomla htpdocs redirect (javascript)   (237 Views)
I have what appears to be a javascript or other type of code in htpdocs of a newer Joomla site, there is a index.htm that I think is causing a 2-3 second delay for the homepages to load up and I would like to remove this... goto myurl for the javascript with a variable, and then it has OnLoad with a url in the body Also is there any quick way to set up a simulator to teach myself this stuff, or can you point me to the documentation I forgot to mention that I tried removing the file and it didn't work
redirect to a new page after form validation carried?   (325 Views)
I have a simple html form and i have a small piece of script which validates it, I would like it so that after the validation is carried out, if the return value is true, then the user will be redirected to index.html i have tried several pieces of code to the end of my validation script but i cant get the page to change Any help would be appreciated Here is my javascript code function validate_form ( ) { var illegalChars= /[\(\)\\,\;\:\\\/\"\[\]]/; valid = true; if ( document.contactform.firstname.value == "" ) { 'Yellow'; alert ( "Please fill in the 'First Name' box." ); valid = false; } if ( document.contactform.lastname.value == 0 ) { 'Yellow'; alert ( "Please fill in the 'Last Name' box." ); valid = false; } if ( { 'Yellow'; alert ( "Illegal Characters" ); valid = false; } if ( == 0 ) { 'Yellow'; alert ( "Please fill in the 'Email' box." ); valid = false; } if ( document.contactform.message.value == 0 ) { 'Yellow'; alert ( "Please fill in the 'Message' box." ); valid = false; } return valid; }
Problem with redirecting (Ajax)   (227 Views)
Hi all, I am having a problem with this js function. If I make it redirect then the rest of the script does nothing. However if I remove the line: window.location.href = "index.phppage=news&cmd=comments&newsid=" + pageid + "&del=1" then all is fine except then there is no redirecting... so what do I need to be doing here function delete_comment(pageid, commentid, type){ var answer = confirm("Are you sure you want to delete this comment"); if(answer == true){ initialize(); var infoStr = "cmd=" + encodeURIComponent(escape('delete_comment')); infoStr += "&commentid=" + encodeURIComponent(escape(commentid)); infoStr += "&type=" + encodeURIComponent(escape(type)); var url = "ajaxrequest.php";'POST',url, true); request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); request.send(infoStr); window.location.href = "index.phppage=news&cmd=comments&newsid=" + pageid + "&del=1"; request.onCompletion = function(){ window.location.href = "index.php"; } } }
Save/load photo no redirection   (383 Views)
Hi all! I have a script with a form with: action="loadPhoto.php" enctype = "multipart/form-data" method="POST" an input type=file and a submit button. So when you click submit the php-script checks that the choosen file is a image-file and that the size isn't to big and saves it to server. When you press the submit button, the file is uploaded, I get directed to the php-page and I redirect back to the origin page where the image is displayed. How can I do this dynamicly I want to press the submit button and not get redirected to the php-page. I just dunamicly want to "wait" on the "submit"-page and show something like "loading...", and when it is loaded, render it on screen again. this without redirection. Please help me!! Marcux
Validating radio button selection for login redirect   (168 Views)
hello, i'm trying to get login functionality to work. It's my first logon script, which was tested to work, but I'm running out of brute force to get this one through... Superior Mini Trucks var num = 0; function login(num) { var loginForm0 = document.getElementById("loginForm0"); var loginForm1 = document.getElementById("loginForm1"); var loginForm2 = document.getElementById("loginForm2"); var loginForm3 = document.getElementById("loginForm3"); var submitForm = document.getElementById("submitForm" + num); if (loginForm0.username.value == "" && loginForm1.username.value == "" && loginForm2.username.value == "" && loginForm3.username.value == "") { alert("Please enter your user name."); return false; } if (loginForm0.password.value == "" && loginForm1.password.value == "" && loginForm2.password.value == "" && loginForm3.password.value == "") { alert("Please enter your password."); return false; } if(num == 0) { submitForm.username.value = loginForm0.username.value; submitForm.response.value = hex_md5(+loginForm0.password.value); submitForm.submit(); } if(num == 1) { submitForm.username.value = loginForm1.username.value; submitForm.response.value = hex_md5(+loginForm1.password.value); submitForm.submit(); } if(num == 2) { submitForm.username.value = loginForm2.username.value; submitForm.response.value = hex_md5(+loginForm2.password.value); submitForm.submit(); } if(num == 3) { submitForm.username.value = loginForm3.username.value; submitForm.response.value = hex_md5(+loginForm3.password.value); submitForm.submit(); } } // end login() window.addEvent('domready', function() { var mySlide_inventory = new Fx.Slide('test'); var mySlide_information = new Fx.Slide('test1'); var mySlide_options = new Fx.Slide('test2'); var mySlide_home = new Fx.Slide('test3'); mySlide_inventory.hide(); mySlide_information.hide(); mySlide_options.hide(); mySlide_home.hide(); $('slidein').addEvent('click', function(e){ e = new Event(e); mySlide_inventory.slideIn(); e.stop(); }); $('slideout').addEvent('click', function(e){ e = new Event(e); mySlide_inventory.slideOut(); e.stop(); }); $('toggle').addEvent('click', function(e){ e = new Event(e); mySlide_inventory.toggle(); e.stop(); }); $('hide').addEvent('click', function(e){ e = new Event(e); mySlide_inventory.hide(); e.stop(); }); $('slidein1').addEvent('click', function(e){ e = new Event(e); mySlide_information.slideIn(); e.stop(); }); $('slideout1').addEvent('click', function(e){ e = new Event(e); mySlide_information.slideOut(); e.stop(); }); $('toggle1').addEvent('click', function(e){ e = new Event(e); mySlide_information.toggle(); e.stop(); }); $('hide1').addEvent('click', function(e){ e = new Event(e); mySlide_information.hide(); e.stop(); }); $('slidein2').addEvent('click', function(e){ e = new Event(e); mySlide_options.slideIn(); e.stop(); }); $('slideout2').addEvent('click', function(e){ e = new Event(e); mySlide_options.slideOut(); e.stop(); }); $('toggle2').addEvent('click', function(e){ e = new Event(e); mySlide_options.toggle(); e.stop(); }); $('hide2').addEvent('click', function(e){ e = new Event(e); mySlide_options.hide(); e.stop(); }); $('slidein3').addEvent('click', function(e){ e = new Event(e); mySlide_home.slideIn(); e.stop(); }); $('slideout3').addEvent('click', function(e){ e = new Event(e); mySlide_home.slideOut(); e.stop(); }); $('toggle3').addEvent('click', function(e){ e = new Event(e); mySlide_home.toggle(); e.stop(); }); $('hide3').addEvent('click', function(e){ e = new Event(e); mySlide_home.hide(); e.stop(); }); }); body { text-align: left; } #test, #test1, #test2, #test3 { background: #222; color: #fff; padding: 10px; margin: 20px; } #test { border: 10px solid saddlebrown; } #test1 { border: 10px solid darkgoldenrod; } #test2 { border: 10px solid darkkhaki; } #test3 { border: 10px solid olive; } a { text-size: large; font-weight: bold; text-decoration: none; outline: none; color: white; border-bottom: 2px solid white; } Please Login                                         Home Error User Name Password  
Check and redirect   (239 Views)
N00b as I am, I have a little problem: I have a gamesite. When a user clicks on a game, a Js script has to check if he has our app installed and if not, it redirects him to our landing page, where he can install that app. This is my code so far, but it does not work: myApp=0; function myAppInit(tool) { myApp=1 } function checkmyApp(){ if(myApp!=1) window.location.href="";} Click here