Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onloadPreventer(fun) {
- if (window.location.hash != "#loaded") {
- //alert(window.location.hash);
- window.location = window.location + "#loaded";
- //alert(window.location.hash);
- fun;
- };
- };
- <body onload="onloadPreventer(anotherFunction(arg))">
- function foo(){ /* ... */ } /* does NOT call foo */
- function bar(){ /* ... */ } /* does NOT call bar */
- foo; /* does NOT call foo */
- foo(arg); /* DOES call foo with arg as argument */
- foo(bar); /* does NOT call bar, and DOES call foo with bar as argument */
- foo(bar(arg)); /* DOES call bar with argument arg, and DOES call foo
- with the returned value of bar as argument */
- function onloadPreventer(fun) {
- if (location.hash !== (location.hash = "#loaded")) {
- fun(); // DOES call fun
- }
- }
- <body onload="onloadPreventer(
- function(){anotherFunction(arg);} /* does NOT call anotherFunction */
- )">
- function fun() {
- anotherFunction(arg);
- }
- document.body.onload = function onloadPreventer() {
- if (location.hash !== (location.hash = "#loaded")) {
- fun(); // DOES call fun
- }
- };
- <html><head>
- <script type="text/javascript">
- var callWhenNoHash = function() {
- console.log('called');
- };
- window.onload = function() {
- if (window.location.hash != '#hash') {
- callWhenNoHash();
- }
- };
- </script></head>
- <body><a href="test2.html">test2</a></body>
- </html>
- <html><head></head><body>
- <a href="test1.html#hash">test2</a>
- </body></html>
- $(window).load(function(){
- var load = "#loaded";
- if (window.location.hash != load) {
- window.location = window.location + load;
- document.write(load);
- };
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement