onload

Load multiple pages in a hidden iframe from a xul-based firefox extension

无人久伴 提交于 2019-12-25 10:01:12
问题 From a xul-based firefox addon, I need to: programmatically create an invisible iframe (once) reuse it to load multiple URLs as the addon runs access the returned HTML after each URL loads Problem: I can only get the first page-load for any created iframe to trigger an 'onload' or 'DOMContentLoaded' event. For subsequent URLs, there is no event triggered. Note: I'm also fine with using the hiddenDOMWindow itself if this is possible... Code: var urls = ['http://en.wikipedia.org/wiki/Internet',

Loading a local file using JavaScript

做~自己de王妃 提交于 2019-12-24 19:27:57
问题 Searching and reading here got me part way to my solution, which is a workaround for loading a text file using oft recommended code such as: function FileRead(U) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari X=new XMLHttpRequest(); } else {// code for IE6, IE5 X=new ActiveXObject("Microsoft.XMLHTTP"); } X.open('GET', U, false ); X.setRequestHeader('Content-Type', 'text/html') X.send(); return X.responseText; } This works well for me, so far, on PCs, but not on

Preload images with JQuery to get dominant colour of image

青春壹個敷衍的年華 提交于 2019-12-24 17:57:36
问题 I created the following testpage: http://methodus.de/wp/ It gets the dominant colour of the images of each blog post and use them for animation when scrolling down the page. Unfortunately, the colour can't be calculated as long as the image isn't fully loaded (see the javascript alert). The animation doesn't work then. When I reload the page, the images where cached by the browser, and everything works like charme. The relevant code is: $('.bg').each(function(index) { var url = $(this).data(

Loading successive select boxes on startup with javascript

我与影子孤独终老i 提交于 2019-12-24 12:42:57
问题 I am trying to populate select boxes from javascript at start up, with each one depending on the previous one. In HTML code I have <body onload="start_up()"> <span id="FirstList">xxxxxxx</span> <span id="SecondList">xxxxxxx</span> Javascript code is function start_up() { load_select('','Type1') load_select(document.getElementById('select_first').value,'Type2') } function load_select(argument,code) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request

Waiting for a file to load (onload JavaScript)

那年仲夏 提交于 2019-12-24 10:00:02
问题 I want to read a text from a file and return it in a function. So here's the important part of my code: function getFileRequest(id, contentType, callback) { var val = "x"; if (window.File && window.FileReader && window.FileList && window.Blob) { var element = document.getElementById(id); var file = element.files[0]; if(file != null) { if(file.type.match("text/xml")){ var r; r = new FileReader(); r.onload = function (e) { val = e.target.result; } r.readAsText(file); } else alert("Wrong file

Javascript calculate image size, after image load

自古美人都是妖i 提交于 2019-12-24 09:58:32
问题 function loader(img) { var imgH = img.height; var imgW = img.width; console.log(imgH, imgW); }; img = new Image(); img.src ='../images/pic1.jpeg'; img.onLoad = loader(img); So, It is exepeted, that I'll get image's size, but I got "0 0" in console. And size of image is 500X700. What's wrong with this code? 回答1: This makes no sense: img.onLoad = loader(img); you want to pass the actual function to the event: img.onload = loader; and use this instead of img within the function. Also you need to

Ajax triggering body's onLoad event

百般思念 提交于 2019-12-24 09:50:00
问题 My whole page is loading again whenever I make a ajax call to load a div. I have noticed that 'body onload=init()' onload event is getting triggered on ajax response and all the initialization is happening again. I don't want that to happen. Is there a way by which only div is loaded through ajax call. <body onload="init()"> ..... ..... <div>...<a href="" onclick="saveView('more')"><b>More</b></a></div> </body> main.js function saveView(arg){ if(arg=="more"){ ajaxGet(baseRef+"all.html",

javascript custom object and image onload

百般思念 提交于 2019-12-24 08:20:18
问题 i am having trouble with image loading and triggering with safari/mobile safari. i have a custom object that draws on a canvas but needs to wait until an object image property has loaded because it uses the dimensions of the image when drawing. the below code works fine on ff but fails in safari: function canvasSlider(){ this.slideImg=new Image(); this.slideImg.src="images/back_button.png"; this.somevalue=55; } canvasSlider.prototype.init = function (){ alert(this.slideImg.complete + ', ' +

Function activates whenever images load

心已入冬 提交于 2019-12-24 08:01:15
问题 This is related to my previous question where the HTML is located: Grouping siblings into a div I found it hard to explain what I was attempting to accomplish so I drew up a quick wireframe representation: I found a different solution from grouping the content and getting the visual that is desired. The image is being held in an anchor tag so I used jQuery to find the tallest img on the page and apply that height to the containing a tag. So instead of vertical-align bottom with a fixed height

Unobtrusive JavaScript onload function [closed]

北城余情 提交于 2019-12-24 02:23:20
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Why does the unobtrusive JavaScript technique require the use of an onload function? Would my unobtrusive JavaScript code work outside of an onload function? 回答1: Global Javascript outside of any function will execute immediately as it's interpreted. onload event is used when you want your JS to