10 examples of 'window onload javascript' in JavaScript

Every line of 'window onload javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
166function iframeOnload() {
167 // 移除提交数据用的表单和iframe
168 if (div.parentNode) { div.parentNode.removeChild(div); }
169 // 释放全局回调函数
170 if (callbackName) { base.deleteGlobalVar(callbackName); }
171
172 onload('success');
173}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

66function window_onload() {
67 init();
68 var div = document.getElementById("result");
69 api_query("user_info", {})
70 .then(response=>{
71 console.log(response);
72 div.innerHTML += '<p>' + JSON.stringify(response)+ '</p>';
73 let data = JSON.parse(response);
74 return data;
75 },
76 error => {
77 console.log(error);
78 })
79 .then(data=>{
80 return api_query("user_cancelled_orders", {limit:100, offset:0});
81 })
82 .then(response=>{
83 console.log(response);
84 div.innerHTML += '<p>' + JSON.stringify(response)+ '</p>';
85 },
86 error=>{
87 console.log(error);
88 });
89}
56function onLoad(win) {
57
58 if(window.arguments == undefined)
59 return;
60
61 document.getElementById('text').value = window.arguments[0].text;
62 document.getElementById('description').value = window.arguments[0].description;
63 document.title = window.arguments[0].title;
64
65 if (window.arguments[0].doShowButtons == true) {
66 document.getElementById('buttons-box').style.display = 'none';
67 }
68
69
70 if (window.arguments[0].validSign != null) {
71
72 document.getElementById('dcryptsignresult').style.display = '';
73 document.getElementById('dcryptsignresult').value = document.getElementById("firegpg-strings").getString("validSignInCrypt") + " " + window.arguments[0].validSign;
74 }
75
76}
1function loadScript(url, callback){
2 alert('url');
3 var script = document.createElement("script")
4 script.type = "text/javascript";
5
6 if (script.readyState){ //IE
7 script.onreadystatechange = function(){
8 if (script.readyState == "loaded" ||
9 script.readyState == "complete"){
10 script.onreadystatechange = null;
11 callback();
12 }
13 };
14 } else { //Others
15 script.onload = function(){
16 callback();
17 };
18 }
19
20 script.src = url;
21 document.getElementsByTagName("head")[0].appendChild(script);
22
23}
57function onloadfunction(){
58 if (persistmenu=="yes"){
59 var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
60 var cookievalue=get_cookie(cookiename)
61 if (cookievalue!="") {
62 document.getElementById(cookievalue).style.display="block"
63 }
64 }
65}
11function onLoad() {
12
13 var search = {};
14 window.location.search.slice(1).split("&").forEach(function (x) {
15 var p = x.split("=");
16 search[p[0]] = p[1];
17 });
18
19 var redirect = search['redirect'];
20 var id = search['id'];
21 var series = search['series'] || search['sid'] || search['epFrom'];
22 if (redirect != undefined) {
23 window.location.href = decodeURIComponent(redirect);
24 }
25 else if (id != undefined) {
26 window.location.href = "watch.html?id=" + id;
27 }
28 else if (series != undefined) {
29 window.location.href = "/engage/ui/index.html?epFrom=" + series;
30 }
31 else {
32 window.location.href = "/engage/ui/index.html";
33 }
34}
23function navigate_to_javascript_onload(test, iframe) {
24 iframe.addEventListener("load", test.step_func(e => {
25 assert_equals(typeof SecurityPolicyViolationEvent, "function");
26 iframe.contentDocument.addEventListener(
27 "securitypolicyviolation",
28 test.unreached_func("The CSP event should be fired in the embedding document, not in the embedee.")
29 );
30
31 iframe.src = "javascript:'Fail.'";
32 }));
33}
340async load(uri = '', ...params) {
341 debugApp('Load page', uri);
342 this.loadURI_ = uri;
343 this.loadParams_ = params;
344 await this.initializeInterception_();
345 debugApp('Navigating the page to', this.loadURI_);
346
347 const result = new Promise(f => this.domContentLoadedCallback_ = f);
348 // Await here to process exceptions.
349 await this.page_.goto(new URL(this.loadURI_, 'https://domain/').toString(), {timeout: 0, waitFor: 'domcontentloaded'});
350 // Available in Chrome M73+.
351 this.session_.send('Page.resetNavigationHistory').catch(e => {});
352 // Make sure domContentLoaded callback is processed before we return.
353 // That indirection is here to handle debug-related reloads we did not call for.
354 return result;
355}
23function _onLoad () {
24 if (!this.content) {
25 this.content = window.JSON && window.JSON.parse ? JSON.parse(this.xmlhttp.responseText.toString()) : eval(this.xmlhttp.responseText.toString())
26 }
27 _super._onLoad.call(this)
28}
129win.addEventListener("load", function onLoad(evt)
130{
131 // load listener not necessary once https://bugzil.la/800677 is fixed
132 var win = evt.currentTarget;
133 win.removeEventListener("load", onLoad, false);
134 if (win.document.documentElement.getAttribute("windowtype") == "navigator:browser")
135 FirebugLoader.loadIntoWindow(win);
136}, false);

Related snippets