JavaScript - Preloading Exteral Javascript
Hi. I'm using lightbox on my site and i love it! However, i have one problem that occurs for people with a slow internet connection. If an image link is clicked on (that would normally be handled by the Lightbox script) before the page has finished loading, the image opens in a new tab instead of being handled by lightbox.
If I were to put the lightbox scripts into the header of my main page (even though there are no images that use it there), would the browsers cache it for use when the user reaches the pages containing my images? Thanks for your time, -Scott Similar TutorialsHey, this is my first post on this forum, just wanted to say HI! Anyways though, here's my dilemma: I have a website with a large banner (241kb). Instead of having the website look bad while the banner (and other images) load, I would like to have a blank page that says "loading" while JavaScript preloads the banner (and other images). Upon completion of the preload, I would like to change document.location. Would something like the following work for such a task? :: Code: image1 = new Image(); image1.onLoad() = imageLoaded(); image1.src = "image1.png"; function imageLoaded() { document.location="index2.html"; } How would I use this image in the next page (index2.html) ? Would I have to implement the image with JavaScript, or could I use HTML? Any comments are appreciated! Thank you I have a page with several javascript (.js files) in the header, is it possible to preload all of these before the actual page content is loaded? I want to hide the javascript execution from taking place after the page has loaded. Any ideas? Thanks! I was trying to find a way to preload images using javascript or PHP or anything that would work - specifically I wanted a way to preload all images from a directory AND its sub-directories. Well, there are solutions out there and some are pretty complex. In the end I chose to do a simple thing which works well for particular image-heavy pages. It is so easy I am wondering why it isn't more often mentioned. OK, it's simply including on a chosen "lead-in" page some almost invisible inline frames (1 px x 1px) of the image-heavy pages you want to preload the images from: Code: <iframe name="I1" src="index1.html" marginwidth="1" marginheight="1" scrolling="no" border="0" frameborder="0" width="1" height="1"> </iframe> <iframe name="I2" src="index1b.html" marginwidth="1" marginheight="1" scrolling="no" border="0" frameborder="0" width="1" height="1"> </iframe> etc. Sure, you have to stay long enough on the lead-in page, but even if you don't, its a help. Here is my solution in action: http://maraboni.aapress.com.au/html/...y/gallery.html (my site went down just as I posted! but it'll be on in a short while, I hope!) You can see that I have used a nice bouncing ball loader routine (pace.js) top right to partially alert the user to what is going on, but it is not essential. Without the inline frames, clicking on the nav links at the top of the page will usually result in a less than optimum visual experience and a necessary page reload of the image-heavy pages. I can't see any downside. Can anyone? Hi! i am working on a facebook like photo viewer. I have used javascript to declare an array of about 200 images. I have the following approach to pre-load the images. I preload all the images when the page loads: HTML: <body onload = "lodpic()"> JAVASCRIPT: function lodpic() { for(i=0; i<=199; i++) { LODImage = new Image(); LODImage.src = picture[i]; } } The problem is the page tries to load all the images when opened. And when the user clicks "next" to view other photos, the other photo is still loading where as some are already loaded. I would like the code to be able to load the photo that the user is currently viewing as the user gets to that picture, before the page tries to finish loading all the photos. In other words, if the user wants to view a particular photo directly, that photo should get the priority of loading quickly. Or if there are other approaches, it would be really helpful. Thank you! 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 Hello! I am trying to find a script that allows you to open multiple browser tabs and then close each of those tabs, either one by one or all at once. Does anyone know how to do this please? Thanks so much for your help. Does anyone know how to make URL links that use Javascript still work when users have Javascript disabled on their browser? The only reason I'm using JS on a URL is because my link opens a PDF file, and I'm forcing it not to cache so users have the latest version. I tried the <script><noscript> tags, but I'm not sure if I'm using it correctly, as my URL completely disappears. Below is my HTML/Javascript code: <p class="download"> <script type="text/javascript">document.write("<span style=\"text-decoration: underline;\"><a href=\"javascript:void(0);\" onclick=\"window.open( 'http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf?nocache='+ Math.floor( Math.random()*11 ) );\" >The Child Magazines Media Kit</a></span> (PDF 1 MB) ");</script> <noscript><span style="text-decoration: underline;"><a href="http://www.webchild.com.au/mediakit/Direct_Media_Kit_Web.pdf" >The Child Magazines Media Kit</a></span> (PDF 1 MB)</noscript> </p> Thanks for any help, Michael Hi Guys, I am new at JavaScript and start to do some tutorials.What I am trying to do here is prompting user to input a name and if the name was valid the page(document) will display with all objects like the button.But if user enter a wrong name then the button will be disabled! I create the following code but it did not work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> <script language="JavaScript" type=""> function changeColor(){ document.bgColor = "Gray"; } </script> </head> <body> <script language="JavaScript" type="text/javascript"> var person = ""; person = prompt('What is Your Name:'); if (person == "Foo") { document.write("<h1 />Welcome " + person); document.bgColor = "Yellow"; } else { document.write("<h1 />Access Denied!!!!"); document.bgColor = "Red"; document.getElementById("gree").disabled = true; } </script> <div> <p/><input id="gree" type="button" value="Gray " onClick="changeColor();"> </div> </body> </html> as you can see I used the: document.getElementById("gree").disabled = true; but it did not work , could you please give an idea how I can solve this problem? Thanks Hi, I have the following code snippet: test.html ====== <script language="javascript" type="text/javascript"> var testVariable = "test"; </script> <script language="javascript" type="text/javascript" src="test.js"> </script> test.js ===== var testVariable = window.top.testVariable; In firefox, I'm able to access testvariable defined within test.html in test.js. But in chrome, test.js couldnot get the window.top.testVariable field defined in test.html. Can any one please let me know how i can make it work in chrome?. Am i missing something here?. Hi Guys I am trying to modify the functionality of my page. I want to be able to activate this piece of code using another javascript function. This is the code I want to activate: Code: <script type="text/javascript"><!-- $('#button-cart').bind('click', function() { $.ajax({ url: 'index.php?route=checkout/cart/update', type: 'post', data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea, .date_data input[type=\'text\']'), dataType: 'json', success: function(json) { $('.success, .warning, .attention, information, .error').remove(); if (json['error']) { if (json['error']['warning']) { $('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.warning').fadeIn('slow'); } for (i in json['error']) { $('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>'); } } if (json['success']) { $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); $('.success').fadeIn('slow'); $('#cart_total').html(json['total']); $('html, body').animate({ scrollTop: 0 }, 'slow'); } } }); }); //--></script> And this is how I want the format of the function to be: function testsession() { if there is a session called 'hiredate' { activate the script above } else { var el = document.getElementById("product_data"); } } I just dont know how to write this in javascript Could you help me if possible please I want to insert this js snippet Code: function addText(smiley) { document.getElementById('message').value += " " + smiley + " "; document.getElementById('message').focus(); return false; } to a loaded iframe with name&id chtifrm. I can access it & change embed something in its html via using something like: Code: $(parent.chtifrm.document.body).append('<div id=\"smly\" style=\"cursor:pointer;float:left;top:200px;display:none;position:absolute;\"><\/div>'); .... Code: parent.chtifrm.document.getElementById('chatbox_option_disco').style.display == 'none' but how do I insert js in the head of loaded iframe? I got an index.php Code: <html> <form action="bacakomik.php" method='post'> <select name="kodekomik"> <option value='../komik1/|23'>Judul Komik1</option> <option value="../komik2/|20">Judul Komik2</option> <option value="../komik3/|10">Juduk Komik3</option> <option value="../komik4/|20">Judul Komik4</option> </select> <input type="submit" /> </form> <?php echo ('<select>'); echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); echo ('</select>'); ?> </html> As you can see, each of the option brings specific value "../komik1/|23" komik1 is a directory | is a delimiter 23 is the pages in one chapter and can be considered also as how many images are there on a specific directory This is my bacakomik.php Code: <?php $dirkomik = $_POST['kodekomik']; $exploded = explode("|", $dirkomik); echo ($exploded[0]); //picture directory echo ("<br>"); echo ($exploded[1]); //total page in the comic $pagecount = (int)$exploded[1]; //Take last posted value, process it right away echo ('<FORM name="guideform"> '); echo ('<select name="guidelinks">'); $i=1; do { echo ('<option value= "'.$i.'">'.'Page '.$i.'</option>'); $i= $i+1; }while($i <= $pagecount); //Printing option and select echo ("</select>"); ?> <input type="button" name="go" value="Go!" onClick="document.getElementById('im').src=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value+'.png';"> </FORM> <img src="img0.jpg" id="im"> With the current code on bacakomik.php, I only can change the img src of id "im" in the same directory only. What I want is that the Javascript could "add" the "$exploded[0]" variable so that the picture can be loaded from different directory. Anyone can do this? I believe that the fix should be somewhere on input tag inside OnClick, or do you know where? Anyway, I found this on the net http://p2p.wrox.com/php-faqs/11606-q...avascript.html Please help me to those who can... Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated All -- I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so: <script type="text/javascript" src="gameSetting.js" ></script> <script type="text/javascript" src="gameLibrary.js" ></script> In gameSetting.js I have: $(document).ready(function() { // call some functions / classes in gameLibrary.js } in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load... $.getScript("gameLibrary.js"); However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem. My options a 1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense. 2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers). jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work. Help appreciated. Nero I wrote a log function that took note of various function calls. Thinking that functions are first class objects, and objects have properties, I made the name of each logged function a property of that function, e.g., brightenInnerPara.name = "brightenInnerPara"; Every browser I tried (Firefox, MSIE, Opera, Chrome, Safari) accepted the assignment, no problem. In Firefox and MSIE, the result was what I wanted: brightenInnerPara.name == "brightenInnerPara" But in the others, the result was: brightenInnerPara.name == null Question 1. Which Javascript is correct here? I favor Firefox and MSIE, not merely because they were willing to give me what I wanted, but also because it makes no sense to accept an assignment statement without throwing an error and then give it a null semantics, like Chrome, Opera, and Safari did. I found a workaround, using assignments like this: brightenInnerPara.prototype.name = "brightenInnerPara"; To my surprise, that worked in every browser. But I don't know why. It seems that such assignments are enough to cause each function to have its own distinct prototype. Question 2. Just how inefficient is my workaround, and why does it work? So i have this: Code: #wrap { background-color:#FFFFFF;filter:alpha(opacity=80);opacity:.6; } And with javascript I want to basically, make turn the opacity up, so i tried this: Code: function mouseOver() { document.getElementById('wrap').style.background-color = "#FFFFFF;filter:alpha(opacity=80);opacity:.9;" } Though it's not working, can anyone help me? I need some help with this Code. I can't seem to get it to go to the page I want it to. You can make a dummy page for example Page 1.html to see if it works for ya. Thanks Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org"> <title>Calculate Groom's Dowry</title> </head> <body> <center> <i><font size="6"><b>Groom's Dowry Rate Calculator*</b></font> </i> </center><br> <br> <br> <br> <i>*Dedicated to all the match making aunties of India</i> <center> <b>Groom's Age</b> </center> <form name="Age" id="Age"> <center> <select name="Groom’s Age"> <option value="a1"> Select </option> <option value="a2"> 23 </option> <option value="a3"> 24 </option> <option value="a4"> 25 </option> <option value="a5"> 26 </option> <option value="a6"> 27 </option> <option value="a7"> 28 </option> <option value="a8"> 29 </option> <option value="a9"> 30 </option> <option value="a10"> 31-35 </option> <option value="a11"> 36-40 </option> <option value="a12"> 41-45 </option> <option value="a13"> 46-50 </option> <option value="a14"> 51+ </option> </select> </center> </form><br> <b>Groom's Caste</b><br> <form name="Caste" id="Caste"> <select name="Groom’s Caste"> <option value="b1"> Select </option> <option value="b2"> Brahmin </option> <option value="b3"> Bania </option> <option value="b4"> Kayastha </option> <option value="b5"> Kshatriya </option> <option value="b6"> Dalit </option> <option value="b7"> Maravar </option> <option value="b8"> Mudaliar </option> <option value="b9"> Nair </option> <option value="b10"> Jat </option> <option value="b11"> Labanas </option> <option value="b12"> Rajput </option> </select> </form><b>Groom's current Profession</b> <form name="Profession" id="Profession"> <select name="Groom’s Profession"> <option value="c1"> Select </option> <option value="c2"> Doctor </option> <option value="c3"> Engineer </option> <option value="c4"> Lawyer </option> <option value="c5"> CA </option> <option value="c6"> IAS </option> <option value="c7"> Engineer + MBA </option> <option value="c8"> Family Business </option> <option value="c9"> None of the above </option> </select> </form><b>Groom's Degree at the Bachelor's Level</b> <form name="Bachelor" id="Bachelor"> <select name="Groom’s Bachelor"> <option value="d1"> Select </option> <option value="d2"> BTech/BE/BS </option> <option value="d3"> MBBS </option> <option value="d4"> BA </option> <option value="d5"> B.Com </option> <option value="d6"> B.Ed </option> <option value="d7"> Bsc </option> <option value="d8"> BBA </option> <option value="d9"> Diploma </option> <option value="d10"> Certification Course </option> </select> </form><b>Groom's Degree at the Master's Level</b> <form name="Master" id="Master"> <select name="Groom’s Master"> <option value="e1"> Select </option> <option value="e2"> MBA </option> <option value="e3"> MS </option> <option value="e4"> MTech </option> <option value="e5"> MPhil </option> <option value="e6"> M.Ed </option> <option value="e7"> MHA </option> <option value="e8"> No Master's degree </option> </select> </form><b>Groom's Degree at the Doctorate Level</b> <form name="Doc" id="Doc"> <select name="Groom’s Doc"> <option value="f1"> Select </option> <option value="f2"> Doctor of Philosophy (Phd) </option> <option value="f3"> Doctor of Medicine (MD) </option> <option value="f4"> No Doctorate Degree </option> </select> </form><b>The Groom is working in</b> <form name="Country" id="Country"> <select name="Groom’s Country"> <option value="g1"> Select </option> <option value="g2"> India </option> <option value="g3"> USA </option> <option value="g4"> Any European Country </option> <option value="g5"> Australia </option> <option value="g6"> Canada </option> <option value="g7"> Any Country more developed than India </option> <option value="g8"> Any Country less developed than India </option> </select> </form><b>Groom's Skin Color</b> <form name="Color" id="Color"> <select name="Groom’s Color"> <option value="h1"> Select </option> <option value="h2"> Fairy White </option> <option value="h3"> White </option> <option value="h4"> Wheatish (Almost White. Would need some Fair n Lovely) </option> <option value="h5"> Brown </option> <option value="h6"> Black </option> <option value="h7"> Pitch Black (Not visible on a moonless night) </option> </select> </form><b>Groom's Height</b> <form name="Height" id="Height"> <select name="Groom’s Height"> <option value="i1"> Select </option> <option value="i2"> Less than 5'4" </option> <option value="i3"> 5'5" </option> <option value="i4"> 5'6" </option> <option value="i5"> 5' 7" </option> <option value="i6"> 5'8" </option> <option value="i7"> 5'9" </option> <option value="i8"> 5' 10" </option> <option value="i9"> 5'11" </option> <option value="i10"> 6' </option> <option value="i11"> 6'1" </option> <option value="i12"> Greater than 6'1" </option> </select> </form><b>Number of times the Groom has married before</b> <form name="Marriage" id="Marriage"> <select name="Groom’s Marriage"> <option value="j1"> Select </option> <option value="j2"> 0 </option> <option value="j3"> 1 </option> <option value="j4"> 2 </option> <option value="j5"> More than 2 </option> </select> </form><b>What is Groom's father's profession</b> <form name="Father" id="Father"> <select name="Groom’s Father"> <option value="k1"> Select </option> <option value="k2"> Engineer </option> <option value="k3"> Doctor </option> <option value="k4"> IAS </option> <option value="k5"> Lawyer </option> <option value="k6"> CA </option> <option value="k7"> IAS </option> <option value="k8"> Engineer + MBA </option> <option value="k9"> Family Business </option> <option value="k10"> None of the above </option> </select> </form><script type="text/javascript"> function Selected_Age(Age) { var myindex = Age.selectedindex; var sel_groom_age = Age.options[myindex].text; return sel_groom_age; } </script> <script type="text/javascript"> function Selected_Caste(Caste) { var myindex_1 = Caste.selectedindex; var sel_groom_caste = Caste.options[myindex_1].text; return sel_groom_caste; } </script> <script type="text/javascript"> function Selected_profession(Profession) { var myindex_2 = Profession.selectedindex; var sel_groom_profession = Profession.options[myindex_2].text; return sel_groom_profession; } </script> <script type="text/javascript"> function Selected_Bachelor(Bachelor) { var myindex_3 = Bachelor.selectedindex; var sel_groom_bachelor = Bachelor.options[myindex_3].text; return sel_groom_bachelor; } </script> <script type="text/javascript"> function Selected_Master(Master) { var myindex_4 = Master.selectedindex; var sel_groom_master = Master.options[myindex_4].text; return sel_groom_master; } </script> <script type="text/javascript"> function Selected_Doc(Doc) { var myindex_5 = Doc.selectedindex; var sel_groom_doc = Doc.options[myindex_5].text; return sel_groom_doc; } </script> <script type="text/javascript"> function Selected_country(Country) { var myindex_6 = Country.selectedindex; var sel_groom_country = Country.options[myindex_6].text; return sel_groom_country; } </script> <script type="text/javascript"> function Selected_color(Color) { var myindex_7 = Color.selectedindex; var sel_groom_color = Color.options[myindex_7].text; return sel_groom_color; } </script> <script type="text/javascript"> function Selected_height(Height) { var myindex_8 = Height.selectedindex; var sel_groom_height = Height.options[myindex_8].text; return sel_groom_height; } </script> <script type="text/javascript"> function Selected_married(Marriage) { var myindex_9 = Marriage.selectedindex; var sel_groom_married = Marriage.options[myindex_9].text; return sel_groom_married; } </script> <script type="text/javascript"> function Selected_father(Father) { var myindex_10 = Father.selectedindex; var sel_groom_father = Father.options[myindex_10].text; return sel_groom_father; } </script> <script type="text/javascript"> var age; var sel_groom_age_1 = function Selected_Age(Age) switch(sel_groom_age_1) { case '23': age = 1.6; break; case '24': age = 1.8; break; case '25': age = 1.7; break; case '26': age = 1.8; break; case '27': age = 1.9; break; case '28': age = 1.75; break; case '29': age = 1.7; break; case '30': age = 1.4; break; case '31-35': age = 1.8; break; case '36-40': age = 1.9; break; case '41-45': age = 1.75; break; case '46-50': age = 1.7; break; case '51+': age = 1.4; break; default: alert ('Please select an option'); } </script> <script type="text/javascript"> var caste; var sel_groom_caste_1 = function Selected_Caste(Caste) switch(sel_groom_caste_1) { case 'Brahmin' : caste = 2.0; break; case 'Bania': caste = 1.8; break; case 'Kayastha' : caste = 1.6; break; case 'Kshatriya' : caste = 2.0; break; case 'Dalit': caste = 1.8; break; case 'Maravar' : caste = 1.6; break; case 'Mudaliar' : caste = 2.0; break; case 'Jat': caste = 1.8; break; case 'Labanas' : caste = 1.6; break; case 'Rajput' : caste = 1.6; break; default : alert ('Please select an option'); } </script> <script type="text/javascript"> var profession; var sel_groom_profession_1 = function Selected_Profession(Profession) switch(sel_groom_profession_1) { case 'Engineer': profession = 1.8; break; case 'Doctor': profession = 1.9; break; case 'Lawyer': profession = 1.65; break; case 'CA' : profession = 1.7; break; case 'IAS': profession = 2.0; break; case 'Family Business': profession = 1.5; break; case 'MBA + Engineer': profession = 1.95; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var bachelor; var sel_groom_bachelor_1 = function Selected_Bachelor(Bachelor) switch(sel_groom_bachelor_1) { case 'BTech/BE/BS': bachelor = 1.8; break; case 'MBBS': bachelor = 1.9; break; case 'BA' : bachelor = 1.1; break; case 'B.Com' : bachelor = 1.4; break; case 'BSc': bachelor = 1.9; break; case 'BBA' : bachelor = 1.1; break; case 'Diploma' : bachelor = 1.4; break; case 'Certification Course' : bachelor = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var master; var sel_groom_master_1 = function Selected_Master(Master) switch(sel_groom_master_1) { case 'MS' : master = 1.9; break; case 'MBA' : master = 2.0; break; case 'MHA' : master = 1.4; break; case 'MTech' : master = 1.4; break; case 'M.Ed' : master = 1.4; break; case 'No Master’s degree' : master = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var doc; var sel_groom_doc_1 = function Selected_Doctor(Doc) switch(sel_groom_doc_1) { case 'Doctor of Philosophy (Phd) ' : doc = 2.0; break; case 'Doctor of Medicine (MD)' : doc = 2.0; break; case 'No Doctorate degree' : doc = 1.4; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var country; var sel_groom_country_1 = function Selected_Country(Country) switch(sel_groom_country_1) { case 'India': country = 1.9; break; case 'USA' : country = 2.0; break; case 'Any European Country ': country = 1.7; break; case 'Australia ': country = 1.7; break; case 'Canada ': country = 1.7; break; case 'Any Country more developed than India ': country = 1.7; break; case 'Any Country less developed than India ': country = 1.2; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var color; var sel_groom_color_1 = function Selected_Color(Color) switch(sel_groom_color_1) { case 'Fairy White' : color = 1.9; break; case 'Black': color= 0.6; break; case 'Wheatish (Almost White. Would need some Fair n Lovely) ': color= 1.4; break; case 'Brown': color= 1.4; break; case 'White': color= 1.9; break; case 'Pitch Black (Not visible on a moonless night) ': color= 0.6; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var height; var sel_groom_height_1 = function Selected_Height(Height) switch(sel_groom_height_1) { case 'Less than 5'4"' : height = 0.6; break; case '5'4"' : height = 0.6; break; case '5'5"' :height = 0.8; break; case '5'6"' :height = 1.0; break; case '5'7"' :height = 1.4; break; case '5'8"' :height = 1.5; break; case '5'9"' :height = 1.6; break; case '5'10"' :height = 1.7; break; case '5'11"' :height = 1.8; break; case '6' :height = 1.85; break; case '6'1"' :height = 1.9; break; case 'Greater than 6'1"' :height = 1.8; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var marriage; var sel_groom_marriage_1 = function Selected_Marriage(Marriage) switch(sel_groom_marriage_1) { case '0': marriage = 1.8; break; case '1' :marriage = 0.7; break; case '2': marriage = 0.4; break; case 'More than 2' : marriage = 0.2; break; default:alert ('Please select an option'); } </script> <script type="text/javascript"> var father; var sel_groom_father_1 = function Selected_Father(Father) switch(sel_groom_father) { case 'Doctor': father= 1.8; break; case 'IAS': father = 2.0; break; case 'Engineer': father= 1.7; break; case 'Lawyer': father= 1.65; break; case 'CA': father= 1.8; break; case 'Engineer + MBA': father= 1.9; break; case 'Family Business': father= 1.2; break; default : alert ('Please select an option'); } </script> <script type="text/javascript"> var total = age + caste + bachelor + master + doc + color + profession + father + marriage + height + country; var pageNumber = Math.floor((20 - total) / 2 + 1); if (pageNumber == 1) { window.location="Page 1.html"; } else if (pageNumber == 2) { window.location="Page 2.html"; } else if (pageNumber == 3) { window.location="Page 3.html"; } else if (pageNumber == 4) { window.location="Page 4.html"; } else if (pageNumber == 5) { window.location="Page 5.html"; } else if (pageNumber == 6) { window.location="Page 6.html"; } else if (pageNumber == 7) { window.location="Page 7.html"; } else if (pageNumber == 8) { window.location="Page 8.html"; } else if (pageNumber == 9) { window.location="Page 9.html"; } else if (pageNumber == 10) { window.location="Page 10.html"; } else { window.location="Page 11.html"; } </script> <form> <input type="submit" value="Calculate"> </form> <br> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Plebeian42">Tweet</a><script type="text/javascript" src= "http://platform.twitter.com/widgets.js"> </script><br> <div style="float: center; padding: 4px;"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php" id= "fb_share">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"> </script> </div><br> <br> <iframe src= "http://www.facebook.com/plugins/like.php?href&layout=standard&show_faces=true&width=450&action=like&font&colorscheme=light&height=80" scrolling="no" frameborder="0" style= "border:none; overflow:hidden; width:450px; height:80px;" allowtransparency= "true"></iframe> <center> ©Creator Name </center><a rel="license" href= "http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src= "http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png"></a><br> This work is licensed under a <a rel="license" href= "http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>. </body> </html> What is so good about javascript? I don't think it is that good, so can someone please explain the pros and cons of JavaScript. I am pretty sure this requires javascript, but right now my coding skills are next to none, but I am trying to teach myself, but for now I still have no idea what I am doing. So here is my problem. I have a site with fairly large images because I am working with a fluid layout, and the background is such that it cannot repeat well, so I placed a loader on the first page so that it can load all the images. I am also using html5 to animate a curtain up the screen, but because of the load time when a user first visits the site, the won't see that animation. Is there anyway that I can pass the amount of time it took to load the site into the delay section of html code. Here is the site: www.franklyon.info Thanks so much! HI All, I'm trying to create a web form that asks for username and password. What im using as validation is http codes. If users inputs correct credentials it will generate a 200 -ok if password is incorrect it will generate a 400 http error. My script is below which i admit is quite rough. but i wish to be pointed in the direction. I want to accomplish the following: If on form submit http is 200 redirect to specified URL. if http 400 i want to add a warning message "Invalid Password, try again" or something like that. ANy help, please. Thanks. --------------------------------------------------------------------- [code] function checkUrl(form1) { var username = form1.username.value; var password = form1.password.value; var url = "https://some url" ; var data = "<cwaRequests xmlns=http://schemas.microsoft.com/2006/09/rtc/cwa>...</cwaRequests>" ; var httpRequest = new XMLHttpRequest(); var isAsync = true; httpRequest.open("POST", url, isAsync); httpRequest.setRequestHeader("Accept", "*/*"); httpRequest.setRequestHeader("UserAgent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50215)"); httpRequest.setRequestHeader("ContentType", "application/x-www-form-urlencoded"); httpRequest.setRequestHeader("Timeout", 1000*60); httpRequest.setRequestHeader("CWA-Ticket", this.authTicket); httpRequest.onreadystatechange = ReadyStateChanged; httpRequest.send(data); function ReadyStateChanged() { if (httpRequest.readyState == 4) { if (httpRequest.Status == 200) { window.location = url var responseText = httpRequest.ResponseText; } else { alert (Password incorrect, Please try again; } } } } [code] |