JavaScript - Javascript Freeze Screen With Loading Image
Hi,
I am an asp.net developer and I wanted to display user popup (kind of) which freezes the screen so that user won't click anything else on the screen. There are some predefined controls in asp.net, but I wanted do this using Javascript. Where can I find a sample with code? Thanks Similar TutorialsI have a form that used php to load a random image but now i would like to use javascript instead and am sure I nearly have it. I need to have a random number between 0 -5. Here is my code Code: <script type='text/javascript'> var random = Math.floor( Math.rand() * 6); document.write("<img src='images/'"+random+"'.jpg' alt='random image' /><input name='image' type='hidden' value='"+random+"' />") </script> Hi, everyone. I've just finally adjusted the way that the background images is laid out. my problem is that the image seems to load in original size and then align to the screen's width. I'm using a javascript code that I got from http://stackoverflow.com/questions/1...g-aspect-ratio and it is working the way I want it to, mostly. My problem is that I'm not sure how to keep the image from exceeding 100% height of the windows without squashing the aspect ratio? I also need to figure out how to fix the visible action of the image being loaded in it's original size? If we can't get the image to load WHILE at the size I want it to be, can we at least 'hide' the image until the loading have been done? I tried to tweak the codes to include the height limitation but it did not seem to have made any differences. This is my first time actually using javascript so please be easy on me, heh My site is at http://www.lost-ear-studio.com (if you refresh the site, you will see random background images being swapped out using php). Code: <script> function resizeToMax(id){ myImage = new Image() var img = document.getElementById(id); myImage.src = img.src; if(myImage.width > myImage.height){ img.style.width = "100%"; } else { img.style.height = "100%"; } } </script> Code: <img id="bg" src="randombg.php" onload="resizeToMax(this.id)"> Code: #bg{ position:fixed; left:0px; top:0px; z-index:-1; } I have the div box Code: <div id="ajax_loader"><center><img src="/css/ajax-loader.gif" alt=""/></center></div> Quote: #filter { display: none; position: absolute; top: 0%; left: 0%; width: 100%; min-height: 900px;; overflow:visible; background-color:#000; z-index:900000; opacity:0.5; filter: alpha(opacity=50); } #ajax_loader{ display: none; position: absolute; top: 50%; left: 50%; z-index:900001; overflow: visible; height:40px; width:60px; background-color:white; vertical-align:middle; padding-top:10px; border:1px solid black; } The problem when the page loads then my content height is around 2000px. So the animations loads on the center of screen but on the upper portion of page which is visible when the page loads. bUt my submit button is at the bottom of page so when i click submit the ani,atiosn stays at the top . I want the animation to load on the screen which is currently visible not which is at the startup Hi all, this is my first post so forgive me for any errors but i'll try and give all the information i can. i use Xara Designer Pro and i have used a 3rd party software to create a html menu however i have a html loading screen on my site and the menu always appears on top of the screen and while the screen is loading, this is the only thing that appears on top everything else is fine, i have put this to the people on the xara forums and the opinion is that its probably the JS file that the menu is using that is telling it to appear on top. i was wondering what i should look for to determin this problem or if someone could take a look at it for me? i'll upload the JS here and see if anyone can help. my site is at www.pcevo.co.uk however you need to CTRL + F5 to refresh wihtout the cache to see the loading screen if you are on a fast connection.
I want to have another go at Javascript. I have several books on the subject but I find that my eyesight is a major problem. Therefore I want to try an on-line solution, preferably free. I have Googled, but there are so many that I am almost dizzy with the choices. Perhaps someone could recommend one. Not too fussy visually. My knowledge is VERY basic. Frank Hi all! I am trying to implement the "Freeze pane" feature in javascript as it is in excel. I am almost there but am not able to get one last thing. The row header freezing is achieved first column freezing is also achieved. However, the top left column cell (which is supposed to stay frozed during both horizontal and vertical scroll) is not frozen. Prompt help is highly appreciated! Please find the html file and the js file being used. Thanks a bunch! Ree Hello everyone! Im new here so any help you can give would be great. I am a Designer, and some time AS3 programer. Teaching my self Javascript for a portfolio website. The Goal: I created a code that randomly creates and Populates Divs in a regular grid, then populates them with an image (using css backgroundImage property) or a print CMY(and Green) color. (eventually will include a shadow box and side scroller) The Problem: The creation and population works just fine, the first time around. if I "Refresh" the page (which i thought destroyed all vars and data) the page loads some times, or freezes. Some times it doesn't load at all! so its very unpredictable, obviously i need this to work the same way every time. Im pretty sure its something simple that i missed, a nuance of javascript or something. So if any one who is more experienced can help I would be super grateful!! here is the page on my website: designchangeseverything.com/beta/divpoptest.html here is the code (i included some of my comments so you can see how i was trying to debug): Code: <SCRIPT LANGUAGE="JavaScript"> var Tborder = .05 var howmanyIMG = 15 var winHeight = Math.floor(window.innerHeight); var winWidth = Math.floor(window.innerWidth); var BoxHeight = Math.floor((winHeight * (1-Tborder)) / 3); var BoxWidth = BoxHeight; var howmanyx = Math.floor(winWidth / BoxWidth) + 1; var howmanyy = 3; var HowMany = howmanyx * howmanyy; var used = new Array(howmanyIMG); var CMYG = ["00AEEF","EC008C","FFF200","41AD49"] function RNDy(numby){ return Math.floor(Math.random()*numby); } function getUniq(){ /* alert("run getuniq");*/ var n; while ( used[ n = RNDy(howmanyIMG) ] ){} used[ n ] = true; return n; } function ColorRND() { if (RNDy(4) ==1) { return true; }else{ return false; } } function PlacePop (HMx,HMy){ var counter = 0; var countc = 0; for(x=0;x<=HMx;x++){ var countr = 0; for(y=0;y<HMy;y++){ var divy = document.createElement("div"); var divyID = 'box' + counter; divy.setAttribute('id', divyID) divy.style.position="absolute"; divy.style.zIndex = counter + 3; divy.style.visibility = 'visible'; divy.style.borderWidth = '1'; divy.style.borderColor = '#000000'; divy.style.pixelLeft= x * BoxWidth + (2 * countc); divy.style.pixelTop= y * BoxHeight + (winHeight * Tborder) + (2 * countr); divy.style.pixelWidth= BoxWidth; divy.style.pixelHeight= BoxHeight; if (ColorRND()){ /*divy.innerHTML = 'color';*/ divy.style.backgroundColor = "#" + CMYG[RNDy(4)]; }else{ /*divy.innerHTML = 'image';*/ divy.style.backgroundImage = "url(resourses/images/portfolio/" + getUniq() + ".png)"; divy.style.backgroundPosition = "center"; /*RNDy(100) + "% " + RNDy(100) + "%";*/ } document.body.appendChild(divy); counter++; countr++; }countc++; } /* alert("ran" + counter + " times");*/ } /* used = null;*/ </script> THANKS FOR ANY HELP YOU CAN GIVE! Hi Guys, I would like to be able to change my webpage background image according to the screen resolution the user uses so: if screen resolution is greater than or equals to 1200*600 then background = mybackground.jpg no-repeat else background = #000000 THANKS A MILLION! Hey guys, I was trying to make a Javascript game that moves an image across the screen randomly. Instead of executing properly, it just shows the image's starting point, and stops. No movement. Is there anyway I could fix this? Thanks, Fizz. Code: <html> <head> <title>Image Mover</title> <style> DIV.movable { position:absolute; } </style> </head> <script language="javascript"> function Start() { var x = 5; //Starting Location - left var y = 5; //Starting Location - top var dest_x = Math.floor(Math.random()*650); //Ending Location - left var dest_y = 500; //Ending Location - top var interval = 10; //Move 10px every initialization moveImage(); } function NewDest() { var x = 5; //Starting Location - left var y = 5; //Starting Location - top var dest_x = Math.floor(Math.random()*650); //Ending Location - left var dest_y = 500; //Ending Location - top var interval = 10; //Move 10px every initialization moveImage(); } function moveImage() { //Keep on moving the image till the target is achieved if(x < dest_x) x = x + interval; if(y < dest_y) y = y + interval; //Move the image to the new location document.getElementById("ufo").style.top = y+'px'; document.getElementById("ufo").style.left = x+'px'; if ((x+interval < dest_x) && (y+interval < dest_y)) { //Keep on calling this function every 100 microsecond // till the target location is reached window.setTimeout('moveImage()',30); if (x == dest_x) && (y == dest_y) { NewDest(); } } } </script> <body onload="Start()"> <div id="ufo" class="movable"> <img src="Mouse.jpg" alt="mouse" WIDTH = 30/> </div> </body> </html> Hi, I want a link on my website where when you press it, it print screens. somthing like, <a href=printscrn();">Print Screen</a> anyone any ideas? Simon Hi Everyone, I have just inherited a website which has a javascript menu tab and picture fader on the home page. This moves through 6 states changing a menu tab and main picture beneath to make it look like you're flicking through the menu yourself. This works perfectly, apart from the fact that every time the picture changes the page flicks back to the top. Very annoying if you have scrolled down are reading things at the bottom of the page!! The page uses jquery-1.2.3.pack.js. I am a PHP man just starting to learn Javascript and don't understand why it is doing this, can anyone help ??? The Relevant Code is: Code: <script> var scurrent_tab='tab1'; var scurrent_click_tab=''; var arTabsMain = new Array ( "tab1", "tab2", "tab3", "tab4", "tab5", "tab6", "bottomtab" ); function ChangeMainPictureClick(s) { bStopAutoLoad = true; ChangeMainPicture(s); } function ChangeMainPicture(s) { scurrent_click_tab = s; $("#tabs_content_container").fadeOut("slow", function() { $("#tabs_content_container").html($('#tabs_content_container_'+scurrent_click_tab).html()).fadeIn("slow"); } ); $('#main_tab_tab1_img').attr('src','images/tab_tab1_off.jpg'); $('#main_tab_tab2_img').attr('src','images/tab_tab2_off.jpg'); $('#main_tab_tab5_img').attr('src','images/tab_tab5_off.jpg'); $('#main_tab_tab4_img').attr('src','images/tab_tab4_off.jpg'); $('#main_tab_tab6_img').attr('src','images/tab_tab6_off.jpg'); $('#main_tab_tab3_img').attr('src','images/tab_tab3_off.jpg'); $('#main_tab_'+s+'_img').attr('src','images/tab_'+s+'_on.jpg'); scurrent_tab = s; } $('#main_tab_tab1').hover ( function(){$('#main_tab_tab1_img').attr('src','images/tab_tab1_on.jpg');}, function(){if(scurrent_tab=='tab1')return;$('#main_tab_tab1_img').attr('src','images/tab_tab1_off.jpg');} ); $('#main_tab_tab2').hover ( function(){$('#main_tab_tab2_img').attr('src','images/tab_tab2_on.jpg');}, function(){if(scurrent_tab=='tab2')return;$('#main_tab_tab2_img').attr('src','images/tab_tab2_off.jpg');} ); $('#main_tab_tab4').hover ( function(){$('#main_tab_tab4_img').attr('src','images/tab_tab4_on.jpg');}, function(){if(scurrent_tab=='tab4')return;$('#main_tab_tab4_img').attr('src','images/tab_tab4_off.jpg');} ); $('#main_tab_tab3').hover ( function(){$('#main_tab_tab3_img').attr('src','images/tab_tab3_on.jpg');}, function(){if(scurrent_tab=='tab3')return;$('#main_tab_tab3_img').attr('src','images/tab_tab3_off.jpg');} ); $('#main_tab_tab6').hover ( function(){$('#main_tab_tab6_img').attr('src','images/tab_tab6_on.jpg');}, function(){if(scurrent_tab=='tab6')return;$('#main_tab_tab6_img').attr('src','images/tab_tab6_off.jpg');} ); $('#main_tab_tab5').hover ( function(){$('#main_tab_tab5_img').attr('src','images/tab_tab5_on.jpg');}, function(){if(scurrent_tab=='tab5')return;$('#main_tab_tab5_img').attr('src','images/tab_tab5_off.jpg');} ); function AutoLoadTopic() { if(bStopAutoLoad) { window.setTimeout(function() {AutoLoadTopic();}, 8000); return true; } iCurrentSlide++; if(iCurrentSlide >= arTabsMain.length-1) iCurrentSlide = 0; ChangeMainPicture(arTabsMain[iCurrentSlide]); window.setTimeout(function() {AutoLoadTopic();}, 8000); } var bStopAutoLoad = false; var iCurrentSlide = 0; window.setTimeout(function() {AutoLoadTopic();}, 8000); </script> // ###### <script> $('#button_start_bottomtab').hover ( function(){$('#button_start_bottomtab_img').attr('src','images/start_bottomtab_pic_on.gif');}, function(){$('#button_start_bottomtab_img').attr('src','images/start_bottomtab_pic.gif');} ); </script> The code 'works' as in there are no issues in its functionality, I just want it work in a better way. Any help or ideas would be greatly appreciated. Hi, I want to load an image when a user clicks a link on my page. The image is a tracking pixel for an affiliate network, so it doesn't need to be visible to the user (as it's not an image anyway but a php file). I assume this would use the onclick event. Can anyone help? So I'm creating a game and decided to use a canvas for the map. The map is a big pictures 500kb+ (6400x6400px) and the canvas size is 320x320 so I am displaying only part of the image at a time and have the page reload on button click for database purposes. What I'd like help with is performance. Currently it's taking a few secs to reload every time and it seems that it causes some cpu strain (can't switch tabs while loading). Could I stop the canvas from reloading the image each time the page is reloaded and if so then how? Can I make the canvas only load a part of the image, if so then how? If neither is possible any tips, solutions how to solve the performance issues? Hi I have a script which dynamically adds contents to an HTML table using the jQuery's .after();... Now the problem the content is a bit too much and some times IE would crash, so I thought if a loading image would solve this issue? Any ideas? Thanks in advance My goal is to replace a 300px x 300px div with a random assortment of pictures, all being 300px x 300px. I however am not that great at JavaScript (I've taken a bigger bite than I can chew) and would love your guys' help. So far this is what I have for my JavaScript: Code: begin(); function begin() { setTimeout(newimage(),7000); } function newimage() { } Which brings me to my first question: What's the best method of pre-loading images? And also, if the method is not through JavaScript, how would I reference the image from the JavaScript? My next step would be to transition between images. (Fading specifically.) I really like the fade transition here and I plan on using that in the site. How would I incorporate that into my code? I noticed he made the entire JavaScript code into one line, which is quite annoying. Thanks guys! I have set javasscript code to detect and store into variable screen resolution. How to store this javascript into variable PHP? PHP Code: <script type="text/javascript"> var ScreenWidth=screen.width; var ScreenHeight=screen.height; var ScreenResolution=ScreenWidth+"x"+ScreenHeight; document.write("<span style=\"color:red;text-transform: capitalize;\">your current screen resolution is " + ScreenResolution + "</span>"); --></script> } </script> <?PHP $screen=str_replace("#","",$resolution); echo "screen width is:".$screen; ?> Hi guys, I am new here and am looking for a bit of help! I am building a website for a friend and am using Javascript. When I preview the site from my computer in Chrome/Firefox then all the JS elements render correctly. I am using jCarouselLite by the way and have used HTML Boilerplate too. However, when I upload the site the Carousel does not work... Also, I seem to have a lot of scripts kicking around inside the html so I will give you a list of those, but here are my external JS files so my question before posting up all the code are 1.) what is the problem with rendering the JS elements live on t'internet, and 2.) can I reduce the amount of JS files/scripts to help page loading times? css_browser_select.js modernizr-1.7.min.js jquery-1.6.1.min.js jcarousellite.js functions.js Code: $(document).ready(function(){ // Activate the main slider $("#mainSlider").jcarousellite({ btnNext: "#sliderBtnNext", btnPrev: "#sliderBtnPrev", visible: 1 }); }); plugins.js script.js jquery.placeholder.min.js and this is the code inside my HTML: Head: Code: <!-- CSS: implied media="all" --> <link rel="stylesheet" href="css/style.css" media="screen"> <link rel="stylesheet" media="handheld" href="css/handheld.css"> <!-- CSS Browser Compatibility --> <script src="js/css_browser_select.js"></script> <!-- Mobile viewport optimized: j.mp/bplateviewport --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects --> <script src="js/libs/modernizr-1.7.min.js"></script> /Head and this is at the bottom of the Body: Code: <script src="js/libs/jquery-1.6.1.min.js"></script> <script src="js/libs/jcarousellite.js"></script> <script src="js/libs/functions.js"></script> <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script>window.jQuery || document.write("<script src='js/libs/jquery-1.6.1.min.js'>\x3C/script>")</script> <!-- scripts concatenated and minified via ant build script--> <script src="js/plugins.js"></script> <script src="js/script.js"></script> <!-- THIS MAY NEED TO BE REDONE! Placeholder for Forms --> <script src="js/libs/jquery.placeholder.min.js"></script> <script> if (!Modernizr.input.placeholder){ $('input[placeholder], textarea[placeholder]').placeholder(); } </script> <!-- Form Submit --> <script> function submitForm() { document.contactPhone.submit(); } </script> <!-- Google Analytics Script - Change UA-XXXXX-X to be your site's ID --> <script> var _gaq=[["_setAccount","UA-XXXXX-X"],["_trackPageview"]]; (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1; g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js"; s.parentNode.insertBefore(g,s)}(document,"script")); </script> <!-- Bookmark Script --> <script> function bookmark_us(url, title){ if (window.sidebar) // firefox window.sidebar.addPanel(title, url, ""); else if(window.opera && window.print){ // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all)// ie window.external.AddFavorite(url, title); } </script> Hi, im having a problem adding a frame busting killer that counteracts a frame killer script on sites so i can load them inside my iframes.. here is the code i use <?php $result = mysql_query("SELECT ru.id, ru.username, ru.owid FROM raidbar_users ru LEFT JOIN raidbar_groups rg ON ru.groupid = rg.id WHERE rg.id = '".(int)$_REQUEST['group']."'") or die(mysql_error()); $myRaidid = raidid(); if(isset($_GET['gm'])) { echo '<FRAMESET rows="*,*,*,30" frameborder="0">' . "\n"; echo ' <FRAMESET cols="*,*" frameborder="0" scrolling="no">' . "\n"; $i = 0; while($row = mysql_fetch_array($result)) { if ($i == 2) { echo ' </FRAMESET>' . "\n"; echo ' <FRAMESET cols="*,*" frameborder="0" scrolling="no">' . "\n"; $i = 0; } echo ' <FRAME src="http://'.$server[$siteConfig['userServer']].'.***********/joinraid.php?raidid=' . $myRaidid . '&suid=' . $row['owid'] . '&serverid='.$siteConfig['userServer'].'">' . "\n"; $i++; } echo ' <FRAME src="">' . "\n"; echo ' </FRAMESET>' . "\n"; echo ' <FRAMESET frameborder="0" scrolling="no">' . "\n"; echo ' <FRAME src="http://'.$server[$siteConfig['userServer']].'.***********/raidmembers.php?raidid=' . $myRaidid . '">' . "\n"; echo ' </FRAMESET>' . "\n"; echo '</FRAMESET>' . "\n"; } else { echo '<table cellspacing=1 cellpadding=1>' . "\n"; echo '<tr>' . "\n"; $i = 0; while($row = mysql_fetch_array($result)) { if ($i == 2) { echo '</tr>' . "\n"; echo '<tr>' . "\n"; $i = 0; } echo ' <td><iframe src="./acct.php?suid=' . $row['owid'] . '" width=450 height=225 scrolling=no frameborder=0></iframe>' . "\n"; $i++; } echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo ' <td><iframe src=http://'.$server[$siteConfig['userServer']].'.***********/raidmembers.php?raidid=' . raidid() . '&serverid='.$siteConfig['userServer'].' width=250 height=30 scrolling=no></iframe>' . "\n"; echo '</tr>' . "\n"; echo '</table>' . "\n"; } ?> Now im told to use the following.. <script type="text/javascript"> var prevent_bust = 0 window.onbeforeunload = function() { prevent_bust++ } setInterval(function() { if (prevent_bust > 0) { prevent_bust -= 2 window.top.location = 'http://server-which-responds-with-204.com' } }, 1) </script> or var prevent_bust = 0; // Event handler to catch execution of the busting script. window.onbeforeunload = function() { prevent_bust++ }; // Continuously monitor whether busting script has fired. setInterval(function() { if (prevent_bust > 0) { // Yes: it has fired. prevent_bust -= 2; // Avoid further action. // Get a 'No Content' status which keeps us on the same page. window.top.location = 'http://server-which-responds-with-204.com'; } }, 1); But the window.top.location i dont know how to incorporate that to work. Can anyone help? I know this was here previously but no solution was found and I wonder if someone could help. JavaScript loads before even DOM is fully loaded but only in Chrome browser. I know I could use setTimeout function but it's now ideal in my case. I am working on a program based on Chromium and have a html page inside it. Page has 4 images that resize (useing javascript) depending on window size Here is load finction Code: window.onload = function(){ window.document.body.onload = initDocument; }; function initDocument() { stretchFit("divMy", "bg"); stretchFit("divG", "bgG"); stretchFit("divTech", "bgTech"); stretchFit("divKB", "bgKB"); } Any ideas how to load function after DOM is loaded? Hi, well i searched at google and was not exactly able to find what i was looking for, i am looking for a script the shows by logo while loading the game at back end, shows loading percentage or bar representing how game is loaded and then makes the my logo disappear once the game is loaded e-g like this site has used http://www.gamegape.com/en-2095-elemental-battles.html if some thing like this is not available can someone atleast tell me how this site has done it, so we could copy it from them ^_^ |