JavaScript - Loading Js Outside Of Head Tag
Is there a way to load up an external JS file outside of the head tag? I've got an "AJAX" web app that's loading several pages simply by changing the innerHTML property of a single div. The JS source is getting to be rather large, so I'd like to split it up into manageable, organized portions. Is there some way to, using javascript or PHP, load another javascript into the browser dynamically?
Similar TutorialsHello all, I have the following code to load a new html page into the 'new content' div once the user scrolls to the bottom of the page. It all works fine. No problems, except I would like it to pause for a moment whilst it is loading, and show a loading box div at the bottom of the screen as it loads the new content, just to give some positive feedback for the user. So the new div would sit in a fixed position at 'bottom:0px;' and have a loading image inside it. Is this easy to do? I am new to javascript so bear with me Code: alreadyloading = false; nextpage = 2; $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) { if (alreadyloading == false) { var url = "page"+nextpage+".html"; alreadyloading = true; $.post(url, function(data) { $('#newcontent').children().last().after(data); alreadyloading = false; nextpage++; }); } } }); The 'new content' is a div which is at the bottom of the page and is where the new content loads to! Thank you very much Hello All, I am having a few issues. I have added a piece of code in and it doesn't seem to be working. I have highlighted this in bold. Any Ideas? <html> <body> <SCRIPT LANGUAGE="JavaScript"> <head> <TITLE>Find the Correct Number Game</TITLE> </head> a=(prompt('please enter your name:',0)); // prompt for player name document.write(' Hello ' ,a); var guessme=Math.round(Math.random()*(49)+1); var speech='Choose a number between 1 and 50'; function process(hiddennumber) { var guessnumber=document.forms.guesstable.guessnumber.value; var speech='"'+guessnumber+ '" Letters are not allowed. Please enter digits only!.'; document.forms.guesstable.guessnumber.value=''; if (guessnumber==hiddennumber) { document.forms.guesstable.prompt.value='Congratulations! '+hiddennumber+' is correct!'; alert ('Well done - the mystery number is '+hiddennumber+'! \n\nIf you want to play again click the button.'); speech=''; document.location=document.location; } if (hiddennumber<guessnumber) { speech='Less than '+ guessnumber; } if (hiddennumber>guessnumber) { speech='Greater than '+ guessnumber; } if (guessnumber=='') { speech='You didn\'t guess anything!' } document.forms.guesstable.prompt.value=speech; document.forms.guesstable.guessnumber.focus(); } </SCRIPT> </body> </html> <FORM onSubmit="" NAME="guesstable"> <CENTER> <TABLE ALIGN="left" BGCOLOR="#888889" BORDER="5" CELLPADDING="5"> <TR> <TD BGCOLOR="#004081"> <FONT COLOR="#ffffff" FACE="Arial"><B>Find the Correct Number</B></FONT> </TD> </TR> <TR> <TD> <CENTER> <INPUT TYPE="text" NAME="prompt" SIZE="31" MAXLENGTH="60" VALUE="Find the correct number which is between 1 and 50"><BR> <INPUT TYPE="text" NAME="guessnumber" SIZE="3" MAXLENGTH="3" VALUE=""> <INPUT TYPE="button" VALUE="Enter" onClick='process(guessme)'> </CENTER> </TD> </TR> </TABLE> </CENTER> </FORM> On one of my pages, I have a dropdown menu as well as a image rotator. The problem is that when I have the menu on a page by itself, it loads like this: Not only does it have arrows, it also loads with a fade in/out. This is what I want. However, when both menu and image rotator scripts are in the head, this is the result: it doesnt have the arrows and doesnt fade in/out. Could someone point out where the two scripts come into conflict and possibly a resolution? Here is the code in the head: Code: <!--main stylesheet--> <link rel="stylesheet" type="text/css" href="css/main.css"> <!--menu stylesheets--> <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen"> <script type="text/javascript" src="js/jquery-1.2.6.min.js"></script> <script type="text/javascript" src="js/hoverIntent.js"></script> <script type="text/javascript" src="js/superfish.js"></script> <script type="text/javascript"> // initialise plugins $(document).ready(function(){ $("ul.sf-menu").superfish(); }); </script> <!--Orbit stylesheets--> <!-- Use the ID of your slider here to avoid the flash of unstyled content --> <style type="text/css"> #featured { width: 940px; height: 450px; background: #009cff url('orbit/loading.gif') no-repeat center center; overflow: hidden; } </style> <link rel="stylesheet" href="orbit.css"> <!--[if IE]> <style type="text/css"> .timer { display: none !important; } div.caption { background:transparent; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000); zoom: 1; } </style> <![endif]--> <!-- Attach necessary scripts --> <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script> <script type="text/javascript" src="js/jquery.orbit.min.js"></script> <!-- Run the plugin --> <script type="text/javascript"> $(window).load(function() { $('#featured').orbit({ 'bullets': true, 'timer' : true, 'animation' : 'horizontal-slide' }); }); </script> Hi, The following code works: Code: <html> <head> <style type="text/css"> img { opacity:0.4; filter:alpha(opacity=40); } </style> </head> <body> <img src="http://www.w3schools.com/Css/klematis.jpg" width="150" height="113" alt="klematis" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> <img src="http://www.w3schools.com/Css/klematis2.jpg" width="150" height="113" alt="klematis" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> </body> </html> But the problem is you have to repeat the inline JavaScript for all <img> tags. I tried to put the script in the head to no avail: Code: <html> <head> <style type="text/css"> img { opacity:0.4; filter:alpha(opacity=40); } </style> <script type="text/javascript"> function getElements() { var x=document.getElementsByTagName("img"); x.style.opacity=1; x.filters.alpha.opacity=100; } </script> </head> <body> <img src="http://www.w3schools.com/Css/klematis.jpg" width="150" height="113" alt="klematis" onmouseover="getElements()" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> <img src="http://www.w3schools.com/Css/klematis2.jpg" width="150" height="113" alt="klematis" onmouseover="getElements()" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40" /> </body> </html> Everything seems right to me, but it doesn't work. Many thanks for any help! Mike can I use javascipt to put in perl <head> for description. what I want to do is something like this <head> <script type="text/javascript"> if $description != (not == to)" " { <meta name="description" content=" $description"> } else { <meta name="description" content=" my site"> } </scipt> </head> <body> run the java script </body> thanks. I am trying something like Code: <script type=\"text/javascript\"> var description == \"mysite\"; if(description != \"$description\"){ document.write(\"<meta name=\"description\" content=\"mysite\">\"); }else{ document.write(\"<meta name=\"description\" content=\"$description\">\"); } </script> http://www.masterclock.com/newContac...help/david.php I have a page with 3 forms. I've got javascript making them appear and disappear with buttons at the top. I mostly copied this guy's form: http://tetlaw.id.au/view/javascript/...eld-validation I added some conditional checkboxes using wform javascript library. my problem is that i need my reset button to a)reset the fields and b)re-hide the conditional fields. It works with the sales form and the catalog form (the catalog from doesn't use the conditional fields) but for some reason the request a quote form is convinced .request isn't a function. Even though it is using the same function as the sales form only it is pushing it's form id to it. what the heck am i doing wrong? And how awful and waste of space is my code? Hello, I am new here. I am having problems with a talking head video on my website www.getvms.com. A young woman pops up and speaks and then when you click on her a form to fill out is supposed to pop up. It works perfect in chrome and FF, but in IE the video just closes. Can someone tell me why that is? Or at least some type of direction? I found that when the script is in there twice it works, but of course that cause the video to echo. Here is the code for the page.... Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta name="verify-v1" content="+E5zkaC6JxDkzTZkPgdW9Gmj8aIXPzDPpIpeBsUDi0s=" > <title>VMS - Velocity Merchant Services - Downers Grove, IL</title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="description" content="Velocity Merchant Services of Downers Grove, IL offers credit card processing for Visa, MasterCard, American Express, and Discover allowing businesses to accept credit cards and debit cards."> <meta name="keywords" content="VMS, Velocity Merchant Services, Credit Card Terminals, Downers Grove Merchant Services, Oakbrook Merchant Services, Accept Credit Cards, Accept Debit Cards, Credit Card Processing, Merchant Service Provider, Merchant Card Services, Downers Grove Business Service, Oakbrook Business Service"> <meta http-equiv="content-language" content="en-us"> <meta name="robots" content="index,follow"> <meta name="googlebot" content="index, follow"> <meta name="revisit-after" content="10 days"> <meta name="author" content="Velocity Merchant Services - VMS"> <link href="style.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="menu/imenus0.css" type="text/css"> <link rel="stylesheet" href="cssverticalmenu.css" type="text/css"> <script src="swfobject.js" type="text/javascript"></script> <link rel="icon" href="/favicon.ico" type="image/x-icon"> </head> <body> <div id="container"> <div id="logo"><img src="images/logo.gif" alt="Logo"></div> <table width="781" border="0" align="center" cellpadding="0" cellspacing="0" style=" margin-top:10px; background:url(images/nav-bkgd.gif) no-repeat center top;"> <tr> <td><script language="JavaScript" src="menu/imenus0.js" type="text/javascript"></script></td> </tr> </table> <table width="781" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="781" colspan="3"> <div id="flasher"><img src="images/photo-home.jpg" alt="Velocity Merchant Services" width="781" height="164"></div> <script type="text/javascript"> var so = new SWFObject("flash_final.swf", "flash_content", "781", "222", "8"); so.addParam("wmode","transparent"); so.write("flasher"); </script></td> </tr> </table> <table width="781" border="0" align="center" cellpadding="5" cellspacing="0"> <tr> <td width="381" valign="top"><a href="about.html" onMouseOver="Tip('<b>Phone:</b> <br> (888) 902.6227 <br> <br> <b>Address:</b> <br> Velocity Merchant Services <br> 3051 Oak Grove Dr. (Second Floor) <br> Downers Grove, IL 60515')"> <h3> Welcome To Velocity Merchant Services </h3> Velocity Merchant Services </a> is a direct processor for Visa, MasterCard, American Express and Discover. Offering multiple payment options for your customers is the first step to increasing your company's cash flow.</p> <p>At VMS we will not only approve you to accept credit cards and debit cards from your customer; but we will help implement proven marketing strategies to help your business grow!<span class="style1"><br> </span></p> </td><td width="380" valign="top"><h3> Are You PCI Compliant?</h3> <P>Make sure your business is compliant with the latest PCI (Payment Card Industry) Data Security Standards to ensure your customers' confidential information is trasmitted in the most secure environment possible. <a href="/pci">Take our quick survey</a> and avoid non-compliance penalties.</P> <P><a href="/pci"><u>Take The PCI Compliance Survey</u></a>!</P> </td> </tr> <tr> <td colspan="2" valign="top"> </td> </tr> </table> <table width="781" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="196" align="center" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" class="mainmenu" style="background-image:url(images/box-top.gif); background-position:top"><h2><a href="agent-services.html">Agent Services</a></h2></td> </tr> <tr> <td valign="top" style="background-image:url(images/box-bkgd.gif); background-position:top center; background-repeat:no-repeat;"> <div class="List"> <ul> <li><a href="become-a-partner.html">Become a Partner</a></li> <li><a href="value-added-services.html">Programs & Services</a></li> <li><a href="login.html">ISO Sales Agent Sign Up</a></li> <li><a href="news.html">News</a></li> <li><a href="resource-center.html">Resource Center</a></li> <li><a href="careers.html">Careers</a></li> </ul> </div> </td> </tr> </table> </td> <td width="195" align="center" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" class="mainmenu" style="background-image:url(images/box-top.gif); background-position:top"><h2><a href="existing-merchants.html">Existing Merchants</a></h2></td> </tr> <tr> <td align="center" valign="top" style="background-image:url(images/box-bkgd.gif); background-position:top center; background-repeat:no-repeat;"> <div class="List"> <ul> <li><a href="service-upgrade.html">Service Upgrades / Additions</a></li> <li class="list-spacing"><a href="customer-service.html">Tech Support / Customer Service</a></li> <li><a href="order-free-supplies.html">Order Free Supplies</a></li> <li><a href="american-express-card.html">American Express Card</a></li> <li><a href="referralprogram.html">Referrals</a></li> <li><a href="faq.html">FAQ's</a></li> </ul> </div></td> </tr> </table></td> <td width="195" align="center" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" class="mainmenu" style="background-image:url(images/box-top.gif); background-position:top"><h2><a href="value-added-services.html">Value Added Services</a></h2></td> </tr> <tr> <td align="center" valign="top" style="background-image:url(images/box-bkgd.gif); background-position:top center; background-repeat:no-repeat;"> <div class="List"> <ul> <li><a href="vms-fast-cash.html">Cash Advances</a></li> <li><a href="gift-cards.html">Gift Cards</a></li> <li><a href="web-development.html">Web Development</a></li> <li><a href="check-services.html">Guarantee Check Service</a></li> <li><a href="eletronic-benefits-transfer.html">Electronic Benefit Transfer</a></li> <li><a href="business-cards.html">Business Cards</a></li> <li><a href="http://www.getvms.com/icharge/">iCharge</a></li> </ul> </div></td> </tr> </table></td> <td width="195" align="center" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" class="mainmenu" style="background-image:url(images/box-top.gif); background-position:top"><h2><a href="merchant-services.html">Merchant Services</a> </h2></td> </tr> <tr> <td align="center" valign="top" style="background-image:url(images/box-bkgd.gif); background-position:top center; background-repeat:no-repeat;"> <div class="List"> <ul> <li><a href="retail.html">Retail</a></li> <li><a href="restaurant.html">Restaurant</a></li> <li><a href="health-pharmaceuticals.html">Health/Pharmaceuticals</a></li> <li><a href="service.html">Service</a></li> <li><a href="mail-order.html">Mail Order / Telephone Order</a></li> <li><a href="ecommerce.html">eCommerce</a></li> </ul> </div></td> </tr> </table></td> </tr> </table> <br> <table width="781" border="0" align="center" cellpadding="20" cellspacing="0" style="background-image:url(images/footer-bkgd.gif); background-repeat:no-repeat" id="footer"> <tr> <td width="541" align="center" valign="middle"><p><a href="index.html">Home</a> :: <a href="about.html">About VMS</a> :: <a href="merchant-services.html">Merchant Services</a> :: <a href="web-development.html">Web Development</a> :: <a href="vms-fast-cash.html">Cash Advances</a><br> <a href="credit-card-terminals.html">Credit Card Terminals</a> :: <a href="request-information.php">Request Info</a> ::<a href="contact.html"> Contact</a> :: <a href="privacy-policy.html">Privacy Policy</a></p> <p>© 2010 Velocity Merchant Services. VMS is a registered ISO and MSP of HSBC Bank, USA<br> National Association, Buffalo, NY</p></td> <td width="160" align="center" valign="middle"><p>Velocity Merchant Services<br> 3051 Oak Grove Road<br> Downers Grove, IL 60515<br> Phone: (888) 902.6227<br> Fax: (888) 902.6229</p></td> </tr> </table> <br> <table align="center" width="781" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left"><table border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="middle"><a href="application.php"><img src="images/creditcards.jpg" alt="Apply Now!" border="0"></a></td> </tr> </table> <p> </p></td> <td align="right"><table border="0" cellspacing="0" cellpadding="0"> <tr> <td><a rel="nofollow" target="_blank" href="http://www.bbbonline.org/cks.asp?id=1061023114246"><img src="images/bbb.gif" alt="Click to verify BBB accreditation and to see a BBB report." width="40" height="64" border="0" title="Click to verify BBB accreditation and to see a BBB report."></a></td> <td style="padding: 0 15px"><a href="http://www.uschamber.com/sb" rel="nofollow" target="_blank"><img src="http://www.uschamber.com/sb/websticker/image.asp?i=a2&m=999999" alt="U.S. Chamber of Commerce Member 2008" hspace="10" title="U.S. Chamber of Commerce Member 2008"></a></td> <td><script type="text/javascript" src="http://sealserver.trustkeeper.net/compliance/seal_js.php?code=w6otlmrNfNOhkhjNVXmBsFWOX2IVM8&style=normal&size=105x54&language=en"></script> <noscript> <a href="https://sealserver.trustkeeper.net/compliance/cert.php?code=w6otlmrNfNOhkhjNVXmBsFWOX2IVM8&style=normal&size=105x54&language=en" rel="nofollow" target="hATW"><img src="http://sealserver.trustkeeper.net/compliance/seal.php?code=w6otlmrNfNOhkhjNVXmBsFWOX2IVM8&style=normal&size=105x54&language=en" alt="Trusted Commerce" border="0"></a> </noscript></td> <td width="179"> <a href="docs/ViewComplianceCertificate.action.pdf" rel="nofollow" target="_blank"><img src="images/compliance%20icon.jpg" width="175" height="74" border="0" align="right" alt="Compliance"></a></td> </tr> </table> <table align="right"><tr><td><p> <!-- <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> </a>--> </p></td><td> <p> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88" border="0"></a>--> </p></td></tr></table> </td> </tr> </table> <script language="JavaScript" src="menu/ocscript.js" type="text/javascript"></script> <script language="JavaScript" src="wz_tooltip.js" type="text/javascript"></script> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-4568625-2"); pageTracker._initData(); pageTracker._trackPageview(); </script> <script language="javascript" type="text/javascript" src="wthvideo/wthvideo.js"></script> </div> </body> </html> for the javascript.... Code: // Copyright 2010 Website Talking Heads // JavaScript Document if (typeof wthvideo == 'undefined') { wthvideo = new Object(); } wthvideo.params = { width:272, height:384, position:"fixed", doctype:"strict", left:"auto", right:"0px", top:"auto", bottom:"0px", centeroffset:"auto", color:0x022918, volume:70, autostart:"yes", fadein:1, fadeout:2, delay:0, delayclose:5, buffertime:3, playbtn:"PlayVideo.png", playposition:"right", playtop:"bottom", exitoncomplete:"yes", oncepersession:"no", vidlink:"http://www.getvms.com/request-information.php", openin:"_blank", path:"wthvideo", actorpic:"rennygetvms3410.png", flv:"rennygetvms3410.flv" }; var topPx = parseFloat(wthvideo.params.top); var bottomPx = parseFloat(wthvideo.params.bottom); wthvideo.hideDiv = function(){ document.getElementById('wthvideo').style.visibility = 'hidden'; } function onlyOnce() { if (document.cookie.indexOf("hasSeen=true") == -1) { var later = new Date(); later.setFullYear(later.getFullYear()+10); document.cookie = 'hasSeen=true;path=/;'; wthvideo.drawVideo(); } } if (navigator.appName.indexOf("Microsoft") != -1) { var topWth = 577; } else { var topWth = 582; } wthvideo.drawVideo= function(){ var markUp = ''; markUp += '<style type="text/css">'; markUp += '#wthvideo {position:'+wthvideo.params.position+';width:'+wthvideo.params.width+'px;height:'+wthvideo.params.height+'px;margin-left:'+wthvideo.params.centeroffset+';left:'+wthvideo.params.left+';right:'+wthvideo.params.right+';top:'+wthvideo.params.top+';bottom:'+wthvideo.params.bottom+';z-index:99999999999;}'; markUp += '</style>'; markUp += '<div id="wthvideo">'; markUp += ' <object id="objvideo" style="outline:none;" type="application/x-shockwave-flash" width="'+wthvideo.params.width+'" height="'+wthvideo.params.height+'" data="'+wthvideo.params.path+'/wthplayer.swf">'; markUp += ' <param name="movie" value="'+wthvideo.params.path+'/wthplayer.swf" />'; markUp += ' <param name="quality" value="high" />'; markUp += ' <param name="flashvars" value="vurl='+wthvideo.params.flv+'&vwidth='+wthvideo.params.width+'&vheight='+wthvideo.params.height+'&actorpic='+wthvideo.params.path+'/'+wthvideo.params.actorpic+'&autostart='+wthvideo.params.autostart+'&exitoncomplete='+wthvideo.params.exitoncomplete+'&vbuff='+wthvideo.params.buffertime+'&vdelay='+wthvideo.params.delay+'&vcolor='+wthvideo.params.color+'&vlink='+wthvideo.params.vidlink+'&openin='+wthvideo.params.openin+'&delayclose='+wthvideo.params.delayclose+'&fadein='+wthvideo.params.fadein+'&fadeout='+wthvideo.params.fadeout+'&vvol='+wthvideo.params.volume+'&playbtn='+wthvideo.params.path+'/'+wthvideo.params.playbtn+'&playpos='+wthvideo.params.playposition+'&playtop='+wthvideo.params.playtop+'" />'; markUp += ' <param name="wmode" value="transparent" />'; markUp += ' <param name="allowscriptaccess" value="always" />'; markUp += ' <param name="swfversion" value="9.0.45.0" />'; markUp += ' </object>'; markUp += '</div>'; markUp += '<div id="highlightWth" style="position:absolute; width:150px; height:30px; left:50%; top:'+topWth+'px; visibility:hidden">'; markUp += '<img src="wthvideo/orangecircledrawn.png">'; markUp += '</div>'; if (wthvideo.params.position == "fixed") { if (wthvideo.params.doctype == "quirks") { if (wthvideo.params.top == "auto") { markUp += '<!--[if IE]>'; markUp += '<style type="text/css">'; markUp += '#wthvideo {position:absolute; top: expression(offsetParent.scrollTop - 1 + (offsetParent.clientHeight-this.clientHeight) + '+bottomPx+' + "px")}'; markUp += '</style>'; markUp += '<![endif]-->';} else { markUp += '<!--[if IE]>'; markUp += '<style type="text/css">'; markUp += '#wthvideo {position: absolute !important;top: expression(((document.documentElement.scrollTop || document.body.scrollTop) + (!this.offsetHeight && 0)) + '+topPx+' + "px")'; markUp += '</style>'; markUp += '<![endif]-->';} } else { markUp += '<!--[if lte IE 6]>'; markUp += '<style type="text/css">'; markUp += 'html, body{height: 100%;overflow: auto;}#wthvideo {position: absolute;}'; markUp += '</style>'; markUp += '<![endif]-->'; } } document.write(markUp); } function hideDiv() { wthvideo.hideDiv(); } if (wthvideo.params.oncepersession == "yes") { onlyOnce();} else { wthvideo.drawVideo(); } function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName]; } else { return document[movieName]; } } function cue0Bright() { document.getElementById('highlightWth').style.visibility = 'visible'; } function cue0Normal() { document.getElementById('highlightWth').style.visibility = 'hidden'; } function cue0() { cue0Bright(); setTimeout("cue0Normal();", 3000); } function cue1Bright() { document.getElementById('highlightWth').style.visibility = 'visible'; document.getElementById('highlightWth').style.top = topWth+38+'px'; } function cue1Normal() { document.getElementById('highlightWth').style.visibility = 'hidden'; } function cue1() { cue1Bright(); setTimeout("cue1Normal();", 1500); } function cue2Bright() { document.getElementById('highlightWth').style.visibility = 'visible'; document.getElementById('highlightWth').style.top = topWth+19+'px'; } function cue2Normal() { document.getElementById('highlightWth').style.visibility = 'hidden'; } function cue2() { cue2Bright(); setTimeout("cue2Normal();", 4000); } I need to get this figured out fairly quickly. As I said the pop-ups work in FF and Chrome, but in IE the program just closes. I have an external .js file that ends its process with a document.write() command. This needs to be called near the end of the HTML page, right before </body>. Am I better off calling the external .js at the desired location in the footer? Or making the .js into a defined function, loading the .js in the <head> portion and then executing the function in the footer? - M. I am very new to learning JavaScript and I already seem to have come across a problem. I can get Scripts to work fine in the <body> but not all scripts seem to work in the <head> For example, this works fine: Code: <html> <body> <p id="date"></p> <script type="text/javascript"> <!-- document.getElementById('date').innerHTML = Date(); //--> </script> </body> </html> However, it won't work if I place the script in the head like this: Code: <html> <head> <script type="text/javascript"> <!-- document.getElementById('date').innerHTML = Date(); //--> </script> </head> <body> <p id="date"></p> </body> </html> It could just be that I broke one of the fundamental laws of coding that I don't know or something but like I said, I've only just started JavaScript. Also, the tutorial I have isn't to clear on the differences between using the <head> or the <body>. Just kinda says you can do both. I'd like to use the <head> wherever possible because it would be so much neater to keep all the JavaScript in one place and all the HTML in another. Pretty much like you can do with CSS. Anyway, I'd be much grateful if somebody can explain this to me. This is really annyoing. I'm trying to set up an image's source from a function within the document's head, but to no avail. The code is something like this: ------------------------------------------------------- <head> .....js code..... function updatePieChart() { document.pie_chart.src = "piechart.php?p1&p2"; // php-generated image, with parameters } // A FUNCTION WHICH SUCCESSFULLY RUNS EVERY 2-3 SECONDS function ajax() { ....stuff..... // THE NEXT LINE DOESN'T WORK!!! // updatePieChart(); ...stuff..... } ....js code...... // THE NEXT LINE DOESN'T WORK!!! // updatePieChart(); </head> //THIS LINE WORKS LIKE A CHARM <body onload="updatePieChart();"> ....bla bla bla... <img src="#" name="pie_chart" /> ...bla bla bla.... </body> ------------------------------------------------------- As you can see, the function updatePieChart works wonderfully from the <body> tag of the function, but any attempt to call it from within the <head> tags fails. Also, I've tried to change the function updatePieChart so that it wouldn't call any php code and changed it to a simple document.pie_chart.src = "#"; but that still causes errors on the page when called from inside the <head> tags. On the other hand, if the function updatePieChart merely made an alert() call, then the ajax element works fine, and every so and so seconds I get an alert. Anyone, help? An explanation how come I can't set the image from within the <head> tags? Hello and thanks for letting me on this forum! Im pretty new to JScript and I am still getting used to it all. I am trying to make a Website that allows values to be selected from one form, transferred to the next form as a summary and then completed. The values are sent to the page fine but my Validation is broken. Here is my LINK code In the Form Code: <form id="Tickets" onsubmit="return ValidateForm()" action="Details.html"> And in the Submit Button Code: <input type="submit" id="OrderTickets" value="Order Tickets" onclick="return ValidateForm()" > My validation is as follows Code: <script type = "text/javascript"> function ValidateForm() { if( document.getElementById('DepartingStation').selectedIndex == " ") { alert( "Please provide a Departing Station!" ); document.getElementById('DepartingStation').focus() ; return false; } if( document.getElementById('ArrivingStation').selectedIndex == " ") { alert( "Please provide an Arriving Station!" ); document.getElementById('ArrivingStation').focus() ; return false; } var Depart = document.getElementById('DepartingStation').value; var Arriv = document.getElementById('ArrivingStation').value; if( Depart==Arriv){ alert( "Train cannot depart and arrive at the same station!" ); return false; } if ( document.getElementById('ReturnTravel').checked=true; { var valueDate = document.getElementById('OutwardDate').value; if ( valueDate== null || valueDate== '') { alert('Please provide an Outward Travel Date!'); return false; } } var valueRetDate = document.getElementById('ReturnDate').value; if ( document.getElementById('ReturnTravelType').checked==true && (valueRetDate== null || valueRetDate== '' )) { alert('Please provide a Return Travel Date!'); return false; } } Id appreciate any help anyone can share on this! Thanks. I want to use some scripts from http://www.dynamicdrive.com Most of them require pasting script in both the HEAD and BODY of the page. Now, the way my WordPress is set up (Egesto theme), is in individual pages, which I cannot find any way to edit their HEAD or BODY. The only HEAD and BODY sections I see are in the Editor section, where I can edit the overall header.php, but that effects every page, I think. Anyways, does anyone know how I can solve this? Thank you. I want to insert a link into an email that opens a new window of a specific size. All of the scripts I find require some code to be inserted into the <head> tag of the page. Obviously this will not work since I am inserting the link into an email. Is there a JavaScript code for opening a popup window that's not dependent on <head> code?
I need the index of an element in a numeric array. I have tried several variations, but all of them return a undefined value. I can look at the dom and see that the value is there, but the code isn't finding it, please help. Code: Array.prototype.indexValue =function (s){ var index = 'It is not here'; for (var i=0; i<orderArray.lenght; i++){ if (orderArray[i] == s){ return i; } } return index; } function move(){ //get the array posstion of the page in the order array var gpid = 38; var num = orderArray.indexValue(gpid); alert(num); } var orderArray=[28,32,38,45,65]; For me, every time it returns, "It is not here". Help. TIA, Adam How to: pass local variable from <head> JS function to <body> textarea I have a JS function in the head that calculates a variable. the function is triggered by the vevent of a button click. when calculation is done, how is it sent back to the page and placed in a textarea or textbox....?? /Beginner issues :/ Hi all, I am using xmlhttp.open();xmlhttp.send(); to send a php content to a div. This php content is again using the same method to get php content from a further page. The content of the div, does not seem to be using the css and javascript files defined in the calling pages <head> section. Does anyone know why this is? Is there a workaround or solution to this problem? It might be easier to understand looking at the code, so Background info: Javascript file: scripts.js client.php ----> loads data from: display_client.php display_client.php ----> loads data from: display_brand.php Code: client.php http://pastebin.com/4EFn9YRf display_client.php http://pastebin.com/BGZAKre2 display_brand.php http://pastebin.com/0a4Pg3gg scripts.js http://pastebin.com/er4dkmPc Thanks! Hi there, Firstly my title may be a bit misleading as I don't i'm not sure how to do it. My situation is that I have a small piece of javascript that 'cycles' through a bunch of URL's (the URL's are reports produced by SSRS). The problem is that each time the javascript loads a new URL it has to generate the report, so I have a few seconds where the screen says 'Generating Report'. What I would like is a system that never displays the Generating Report, instead I would like to maybe pre-load the next report so it is ready to show instantly. Does anyone have any idea how to do this? Any help would be greatly appreciated. Cheers, Tom. Hi everyone, I am having trouble getting a loading bar to appear from my javascript. I have the following code in place Code: $(document).ready(function(){ $(window).scroll(function(){ var h = $('#footer').height(); var y = $(window).scrollTop(); if( y > (h*0) && y < (h*1.0) ){ $('#loading').fadeIn("slow"); $('#loading').delay(10000).fadeOut(); $("#portfolios").delay(1000).fadeIn("slow"); } }); }) I have it so when the user reacher the 'footer' div of the page, new posts appear which are contained in the 'portfolios' container div. They appear fine but no loading bar appears... The loading bar 'gif' is in the 'loading div id'. There is a 'display:none;' in the css on the loading div and the portfolios div. Any reason why the 'loading' div doesn't display but the portfolios does? I want the loading gif to show whilst the 'portfolios' is loading basically when the user hits the bottom of the page. Any help would be appreciated! Thank you! hello, I'm trying to load the ads on my site dynamically and have ran into an issue and was hoping for some help. First - I can get the ads to load using vanilla javascript with the code below. Code: var ifrm = document.createElement("iframe"); ifrm.setAttribute("src", OAS_url + "adstream_sx.ads/" +sitePage + "/" + uniqid() + "@" + pos); var ifrmId = "ifrm_" + uniqid(); ifrm.setAttribute("id", ifrmId); ifrm.setAttribute("marginwidth", 0); ifrm.setAttribute("marginheight", 0); ifrm.setAttribute("frameborder", 0); ifrm.setAttribute("scrolling", 0); ifrm.setAttribute("height", container.scrollHeight + (container.offsetHeight - container.clientHeight)); ifrm.setAttribute("width", container.scrollWidth + (container.offsetWidth - container.clientWidth)); container.appendChild(ifrm); But since the site is using jquery I wanted to develop it out that way. So I have the following code, Code: iRandom = oas.uniqid(); sAdURL = opt.url + 'adstream_mjx.ads/' + opt.sitepage + '/1' + iRandom + '@' + sPos + '?' + opt.query; $('<iframe />', { src: sAdURL, id: sPos }).appendTo(thisAd); I figured the reason this isn't working is the difference between appendChild and appendTo and the fact that things are jquery objects. So again the top code block renders the ads and the lower code block just shows the javascript code from the ad provider. Any help to get this to work in jquery would be grateful. Thanks for some reason I can't get this code to load... Code: <script type="text/javascript"> alert("test"); windowBody = document.getElementById("windowBody"); windowBody.style.height = (frameHeight - 250) + "px"; </script> that should load when it loads the file foot.php foot.php should be included onto the bottom of all of my labs (and it is) my labs are opened up with Ajax... but the script its not loading at all... someone help =[ the web site is http://opentech.durhamcollege.ca/~in...rittains/labs/ sorry for the poor description I'm having a hard time describing this error lol |