Back button in IE9 - javascript

When I run my application in IE9, back button doesn't work in other browser it does work.
The flow of application is it displays 2 panels, on the page is loaded the first link from left panel get selected and output is displayed in right hand panel. At that point I change the browser hash and adds the URL which is used to display output in right hand side. When I use back button at that point it doesn't work in IE9 but does work in Chrome and FF.
After putting some console.log statements I observed that initially the hash is blank and and insert my new hash to it but when I hit back button IE goes to the blank hash and does nothing but other browsers properly goes to the previous pages.
I am using window.onhashchange.
I noticed that when I click on back button window.onhashchange event gets fired only in IE9 and IE10 but not in other browsers.

This was problem from my end, I was using DHTMLX code and there was a problem in my code.

Related

How would you stop a page from refreshing automatically?

I have a problem when I am trying to check the source of an interesting page which keeps refreshing automatically every 3-5 seconds (presumably due to some js script) which resets my Inspect Element Inspector window every time the page is refreshed.
Is there any other way other to stop that page from refreshing or perhaps the Inspector window from resetting itself other than turning on NoScript to stop the page from refreshing automatically?
Usually I just open DevTools, switch to the appropriate panel if necessary, and hit pause.
Opening DevTools: Via menus, or by press F12, Ctrl+Shift+I, or Cmd+Shift+I depending on browser and OS.
Switching panels: Pick the panel from the tabs at the top of DevTools. It'll be called "Debugger" (Firefox, IE) or "Sources" (Chrome) or similar.
Pausing: In the Debugger/Sources panel, click the pause button (usually looks like the pause button on a television remote control, ||) or press the keyboard equivalent. Keyboard equivalents are
Firefox & Chrome: F8
IE: Ctrl+Shift+B
(Updated 2020-03-30)
In Firefox 74 this option is in Options -> Privacy & Security -> Permissions
(Original reply)
Firefox has the option to prevent refresh natively, the option is in Advanced->General->Warn me when websites try to redirect or reload the page
The most popular solution for this problem is to trap the beforeunload event. The browser will ask the user for confirmation to leave the page. The code, in its simplest form, looks like this:
window.onbeforeunload = function() { return true }
You can enter this code in console. Alternately, you can simply paste the following URL in the browser address bar (console not required). You can even bookmark it.
javascript:window.onbeforeunload = function() { return true }
Be advised that modern browsers might chop off the javascript: part when you paste it inside the address bar; make sure you type it back.
To determine the cause of redirect in Firefox, try the following:
Open Web Developer Tools (CTRL + SHIFT + I), open "Toolbox Options" and check the "Enable persistent logs" option. This makes the logs persist across page loads (logs are cleared otherwise).
Now switch to "Network Monitor" tab.
Open the URL and let it refresh.
Inside the Network Monitor > Cause column you will find out why the page reloads.
The cause column is pretty ambiguous (Chrome does a much better job). However, if JavaScript was used to trigger page (re)load then it at least shows you the filename and line number of that script.
When the page is still loading, you can press the Esc key. While the page is still white, press it. When you stop the page from loading at this point, this usually stops all the auto loaded javascript. Any scripts that run on actions are usually not effected. Each page is different, try different timings.
When I use a site called NovelUpdates there is javascript that can make certain elements hidden, and when I press Esc on page load all the elements that would be hidden after page load are visible. Then when I click a button that would execute javascript that operates with no problems. NoScript isn't going to solve your issue I believe.
Another example of this are those websites with annoying boxes that pop out after 10 seconds that says you aren't a member and can't view any more of this site without logging in, like some news article websites.
What you could do is use the command exit(), which is the equivalent to die in php and simply stops the script.
If you don't know what's causing it and you don't want to look for the "bad boy", then you might as well stop the entire script at the very bottom of the page.

Javascript - Input/text can't get focus (Chrome)

I'm doing a registry form, one of the validations is to check the database for existing username. To do that I open a php page in a separate hidden frame that checks the database and then calls a javascript funcion on the main frame to show an icon indicating if the user exists or not.
everything works fine, except in chrome that when the php page is open, the input/text loses focus and there's no way to get it back. I've tried calling focus on the element, using timeout as i've seen this solves similar issues in chrome, but nothing works so far...
any ideas?
Thanks.

Changes in code not taking effect - Visual web developer

I have a button which is calling a function that displays an alert. The alert is displayed but if I change the messege that the alert is showing, when I press the button the alert will still show the first message I wrote and not the updated one.
It is also happening when I add html tags, they won't show when I run the code.
Why is this happening?
You know the drill: make some edits to your document, click save, switch over to your browser, refresh it, and then observe the changes.
However, every now and again I will catch myself viewing the wrong site page, viewing the site on a different browser, or viewing the client's old live site! Check your address bar + go into your folder and open the page again.

Dynamically generated onclick triggering the wrong event in IE

So I have a 4 window frameset that is setup so that when the main content page loads, it changes the menu options on the left frame menu. Everything works correctly in FF and Chrome, but IE is giving me a problem. I think the problem lies in the javascript.
In IE, the menu items correctly change text, but when clicked on seem to trigger the wrong link. I have an example setup here.
Click on Customer Login on the left, then Sign Up in the main content area. From here, if you click on New Order/Browse, you'll arrive at the Create Order screen when using FF or Chrome. In IE, you'll find yourself back at the login screen.
I need help in getting the menu links on the left working correctly in IE7.

chrome safari javascript jquery back

Is there anything particular to chrome or safari that would make a javascript/jquery script work on the first page load, but then when the user hits the back button after navigating the site, it causes select boxes to be selected?
Here is the code. Apologizes before hand for the lack of conventions. I had to get this up quick:
http://www.mailcanarias.com/index.php
I believe that's because (at least Safari) auto-refills forms when you go back

Categories