I have one HTML <form>. The form has only one action=”” attribute. However I wish to have two different target=”” attributes, depending on which button you click to submit the form. This is probably some fancy JavaScript code, but I haven’t an idea where to begin. How could I create two buttons, each submitting the same form, but each button
How do you execute a JavaScript function when the page has fully rendered?
How would you go about executing a JavaScript function when the page is fully rendered (Displayed) I know that the onLoad event executes when the page is loaded but Before it’s rendered. I’ve previously solved this problem by using a timeout with a 0 interval, which seems to work usually, but seems a little inelegant to my delicate sensibilities. Is
Execute JavaScript code stored as a string
How do I execute some JavaScript that is a string? Answer With the eval function, like:
Get current URL from IFRAME
Is there a simple way to get the current URL from an iframe? The viewer would going through multiple sites. I’m guessing I would be using something in javascript. Answer For security reasons, you can only get the url for as long as the contents of the iframe, and the referencing javascript, are served from the same domain. As long
“Please wait” image on every user action with ASP.NET 3.5
In our ASP.NET 3.5 application, we would like to implement a “Please wait..” feature : on every user action (button click, tab change, etc.) we would display a little spinner on top of the page (actually in a separate frame that we use already have). We thought of this solution : “hijack” the _doPostBack to intercept every event, display the
JavaScript function not working in Mozilla
Below function is working fine for IE, but not working for Mozilla and other browsers: What I am trying to do is, I have a button on a page after clicking on that button, a page in opened in new window having session, the session will be maintained until user closes the browser. on the new page there is right
How do you stop an infinite loop in Javascript?
Let’s say I accidentally wrote this: …and then ran it. Apart from killing your browser, is there a way to stop javascript execution (the equivalent of Ctrl+Break in basic, or Ctrl+C)? Normally, after about 30 seconds your browser asks if you want to stop the long-running script, but this doesn’t always happen (as I just found out)! FYI: A simple
How can I get query string values in JavaScript?
This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. Is there a plugin-less way of retrieving query string values via jQuery (or without)? If so, how? If not, is there a plugin which can do so? Answer Update: Jan-2022 Using Proxy() is faster than using Object.fromEntries()
Prevent click event from firing when dblclick event fires
I’m handling both the click and dblclick event on a DOM element. Each one carries out a different command, but I find that when double clicking on the element, in addition to firing the double click event, the click event is also fired twice. What is the best approach for preventing this behavior? Answer In a comment, you said, I
When serving JavaScript files, is it better to use the application/javascript or application/x-javascript
The whole question fits in the title. And to add some context: I’m not asking what is the best according to what the specs are saying, but rather what works the best given the mix of browsers deployed nowadays. Some data points: Google uses text/javascript for the JS used on their home page. Google uses text/javascript on Google Docs. Google