If you write javascript:document.forms[0].submit(); in the location bar, automatically it submits the form, which bypass the form validation. It there any trick to block this form submit?
I was looking for a way to have a popup window appear when someone left my page, but not have it appear when they hit the refresh or back buttons on the browser. Since using onUnload="..." in the body tag causes the window to appear when you hit the refresh or back buttons, that didn't do what I wanted.
After doing Google searches for many days I never did find an answer for how to do this. I thought I could have each page open the popup onUnload, but then also have each page close the window onLoad, so the window only stays visible if you actually exit from my whole website. The problem is, I didn't have the handle to the window object in the page that wanted to close the window. I tried passing the handle in a cookie, but that didn't work either.
My solution, which I haven't seen anywhere else before, works like this:
Every page (they are php) includes the same header which has this code in it:
var exit = true; <?php $popstuff = file_get_contents("_popstuff.txt"); $values = explode("|",$popstuff); $usepop = $values[0]; if ($usepop!="on") { echo("exit = false; "); // turn off popup window } ?> function offerWindow() { if ( exit ) { offerPop=window.open('_offer.php', 'offer','width=425,height=298,resizable=0,toolbar= 0,location=0,directories=0,status=0,menubar=0,scro llbars=0'); offerPop.blur(); window.focus(); } } function noExit() { exit = false; } function closeOffer() { offerPop=window.open('_offer.php', 'offer','width=0,height=0,resizable=0,toolbar=0,lo cation=0,directories=0,status=0,menubar=0,scrollba rs=0'); offerPop.close(); } // End --> </script> </head> <body onUnload="offerWindow();" onLoad="closeOffer();">
Now what happens is if you leave the page it opens the popup, but before you even get to see it, the next page closes it (by window name instead of by handle). If you close the browser, or leave the whole web page then the popup remains. If there is a path you wish to take out of the site that does not show the popup then just include onClick="noExit()" to the link and it turns off the popup. Normally the links that go from page to page within the website will all include the "noExit()" call so the popup never even shows up. But the problem where the popup shows up on browser refresh or back buttons just goes away.
Ive been having a problem of late with one of my sites that uses PHP5 / Ajax. The problem is that periodically the ajax functions lock up and it gets stuck in the loading phase of the request. If i restart the apache server everything goes back to normal (i assume it severs the connection to the ajax called function).
I think this is a problem with the javascript part as i have tried it using a straight post request and have have no problems and slow loading time is localized to the one user (ie. still works fine on the other computers on my office network).
I have recorded this happening in Firefox, safari and IE6 & 7
My server is running debian with apache2 and php5
Just wondering if somebody can shed some light on what my problem may be? Code:
I've got the following site that loads great in FF and Chrome (no surprise), but is terribly slow in IE7. It's even quick in IE6, but not 7. Here's the site code...
Now I'm using JQuery in a couple places, but it's by no means nothing crazy. The page is fairly simple.
I thought of preloading the main content images, but even after they are loaded in the cycle, the loading time is still slow.
I read somewhere that putting Javascript code after CSS code on webpages makes them feel like they load faster. I was wondering if any of you has any experience with this and if you do follow this rule in your projects.
I have been looking at this code for two evenings now, and rewrote it 4 times already. It started out as jQuery code and now it's just concatenating strings together.
What I'm trying to do: Build a menu/outline using unordered lists from a multidimensional array.
What is happening: Inside the buildMenuHTML function, if I call buildMenuHTML, the for loop only happens once (i.e. only for 'i' having a value of '0'.) If I comment out the call to itself, it goes through the for loop all 3 times, but obviously the submenus are not created.
I'm looking to send a loop variable (i) to a function inside the loop, but I can't seem to get it to use the value I want, it keeps making it a reference of i and therefore the function is always called using the last value of i rather than the one it was set with.
So if i have 5 Tabs then Tab 1, when clicked, should call DefaultTabClick(0) and so on rather than always using 4 for any of the tabs.
I am new at this jquery stuff. In fact, I'm more of a cut and paste kind of gal I have a web page that I incorporated a slideshow. The picture seems to change a bit faster than I'd like, and I can't seem to make the picture go slower than it already is. Can anyone tell me what value I need to change to accomplish this? I changed a couple numbers, but didn't seem to have an affect. Also, is there a way to add a pause and play button so if the fading picture bothers someone, they can pause it?
But the speed is considerably slow when the datas is large. I know that I can use just string concatenation and html() finally to speed it up but what can I do with the data()?
I'm justing wondering about the behavior of JS in regards to adding elements, suppose I have something like this:
I'm just wondering at the point I hit that "// DO SOMETHING WITH ONE OF THESE DIVS", are all the divs I have added in the DOM available to access?
I ask because I have some code at work in which a tester is reporting an error that happens which I can't reproduce, and they and others have had it a few times.
The only way I can explain it in my mind is if the div is not available to me at the time of execution. So I'm just looking to rule it out or confirm my hunch.
Is document.getElementById("myDiv").appendChild(obj); synchronous and the next line of code wont execute until the DOM is ready or is it in fact a asynchronous call and therefore adding alot of elements to the DOM could result in a lag so some divs or not available straight away.
In the home page (index.html) i have a flash intro. The first time a user sees the website, the intro should play. Once he goes to another page (about_us or contact_us) and comes back to the home page, it should show a different swf (the version without the intro) - i have created two swf files. I need to know how to change them when the user has already seen the intro or was in the home page before. When i googled, i found something on cookies. I have no clue on how to set them and change the swf file.