大约有 17,000 项符合查询结果(耗时:0.0160秒) [XML]
How to get and set the current web page scroll position?
...in hidden variables. Then in the html of the refreshed page I use <body onLoad="window.scrollTo(x,y), where x and y are those from the hidden values values!
– xyz
Nov 4 '10 at 14:32
...
Open popup and refresh parent page on close popup
I opened a popup window by window.open in JavaScript, i want to refresh parent page when I close this popup window.(onclose event?) how can I do that?
...
How do I check if file exists in jQuery or pure JavaScript?
How do I check if a file on my server exists in jQuery or pure JavaScript?
17 Answers
...
How to submit a form with JavaScript by clicking a link?
...tener("click", function () {
form.submit();
});
Enclose the latter JavaScript code by an DOMContentLoaded event (choose only load for backward compatiblity) if you haven't already done so:
window.addEventListener("DOMContentLoaded", function () {
var form = document.... // copy the last code ...
Ajax, back button and DOM updates
If javascript modifies DOM in page A, user navigates to page B and then hits back button to get back to the page A. All modifications to DOM of page A are lost and user is presented with version that was originally retrieved from the server.
...
Image loaded event in for ng-src in AngularJS
...
Here is an example how to call image onload http://jsfiddle.net/2CsfZ/2/
Basic idea is create a directive and add it as attribute to img tag.
JS:
app.directive('imageonload', function() {
return {
restrict: 'A',
link: function(scope, elem...
How do I convert an existing callback API to promises?
...load() {
return new Promise(function(resolve, reject) {
window.onload = resolve;
});
}
You would then use the resulting promise like so:
load().then(function() {
// Do things after onload
});
With libraries that support deferred (Let's use $q for this example here, but we'll...
How do I pass the this context to a function?
...
Another basic example:
NOT working:
var img = new Image;
img.onload = function() {
this.myGlobalFunction(img);
};
img.src = reader.result;
Working:
var img = new Image;
img.onload = function() {
this.myGlobalFunction(img);
}.bind(this);
img.src = reader.result;
So basically:...
Checking if jquery is loaded using Javascript
...ame $() syntax.
Remove your $(document).ready() (use something like window.onload instead):
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
}
...
How to focus on a form input text field on page load using jQuery?
...
You can use HTML5 autofocus for this. You don't need jQuery or other JavaScript.
<input type="text" name="some_field" autofocus>
Note this will not work on IE9 and lower.
share
|
improve...