JavaScript - Load Same Javascript File Two Times On Same Page
I have a question is it bad or what are the disadvantages of doing what I am going to explain.
I want to put the same javascript file two time in the same page e-g Code: <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script> <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script> Now many people will ask why would I want to do that, well the reason is that I am using blogger and blogger doesn't let me see all code from which the page is made rather split it into two parts named as POSTS and EDIT HTML. So I am going to place this script in those both areas but at the end when the page loads it is actually going to two the same script two times which is not error. Another question would be why am I not using same script in one place rather than two places if at the end the page code is going to become one. Well the answer would be because that script is used by other scripts too so I CAN'T CHANGE THE LOCATION if I do so, then the script stops working. Similar TutorialsHello, I don't know if this can be done in Javascript, or requires any other language but i was wondering if this would be possible. I would like to embed this Javascript code in to a PHP file and then for it to run automatically upon the PHP file loading: Code: <td class="smallDesc"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </td> The Javascirpt is the Facebook Share button that basically allows users that have Facebook to share the page there currently on in their Facebook status by pressing the button, but if there not logged in it shows the login page, not a problem just continue the script. The current button i which is what i want to load automatically in the PHP file is located here, to test the functionalilty just click "Share" button in blue.. http://watch-movies-online.anyfilman...-Movie-17.html To summarise, i would like the above Javascript code to execute automatically upon pageload of this PHP file.. http://www.watch-movies-online.anyfi...p://google.com. If that could be done, and if this also is possible.. i would like for the "Share" button on the external page that is loaded from the Javascript code above to be clicked automatically so in effect when ever someone visits the PHP page after clicking "Click Here to Watch/Stream 2012 Online For Free" on this page it will automatically load the Facebook Share box, and automatically click the "Share" Button and then close the page if possible, but not required. Please feel free to ask any questions, i'll be happy to answer. Thanks in advance. Best Regards, Jonathan. I've been doing some research on javascript's impact on the time it takes for a page to load, as defined by firebug's "Net" tab's "onload" demarcation (the red line). It seems that aside from dynamic data that's not part of the HTML, enabling javascript always slows down the page. I've checked wikipedia, yahoo, digg, even google; a javascript-enabled loading of each site shows a later onload() event compared to loading the same site without javascript enabled. My question: Can anyone think of a site that loads faster with javascript than it does without javascript? I have looked all over for an answer to this, but haven't found a definite way to do it yet. I am updating my audio page (a demo track list for getting composing work) and getting rid of my flash audio player in favor of embedding .mp3 files, or adding them with the HTML5 audio tag. What I would like to be able to do is link into the page, and have that link autoplay a specific track out of the 10-20 that I will have on the same page. The problem is I am extremely new to scripting and have no idea where to even start with this. The reason I want it to be able to autoplay specific tracks is so I can market a specific track, and have that person (who is already expecting to hear the music on page load) not have to then look through the track list for that one track I was promoting and click play. Any help would be greatly appreciated, Thanks! Hi - I have an ASP.Net 2.5 application and I need to call a javascript function when one of the pages loads initially. I've tried: Code: string ScriptToCall = @"EnableCheckboxes(" + cblDetails.ClientID + ", false);"; ClientScript.RegisterStartupScript(this.GetType(), "addScript", ScriptToCall, true); where EnableCheckboxes is a javascript function on the page. This doesn't work (doesn't disable the CheckBoxList), although the EnableCheckboxes function DOES work when I call it in other ways, so I'm sure that the problem is that I'm not calling it properly on page load. I've tried: Code: ClientScript.RegisterStartupScript(this.GetType(), "addScript", "alert('Hello');", true); which DOES work, so I know I'm on the right track, but how do I do this? Thanks! Hello! I am developing my personal website! And I am trying to implement it with JS completely. which means I need the page to be one front end page. But the back-end pages would be the ones which do the work and calculations! In other words and more explaination: I would like to have one "index.php" page that contains only a nav bar which handles the mission. Once the page load it loads with the content of "home.php" (the landing page) if the "contact" tab is clicked then I would like to load the "ContactMe.php" page content. I have done this already! but the problem is: "home.php" uses alot of javascript functions and jquery plug-ins. when I load it, it looks messy that you think the JS is disabled in your machine :-\ Note: the loading has been done with those methods: .load(), $.ajax! -> same results! The conclusion: * "home.php" * "ContactMe.php" * "About.php" Is it possible to load those pages in the "index.php" and still have their JS functions function correctly and display as if they were accessed individually? The goal that I am trying to achieve is that I make my whole website for the visitor as "One Page Site"! I am challenging myself with it though! Thank you in advance for your informative posts! Please Note that I have only put the <html><head><body> tags in the index.php and removed them from the back-end pages such as home.php, contactme.php and about.php! for that sake that it works correctly! but with no hope! hello Friends In my jsp project i am using the calendar control which selects the Birth Date of the client and on that basis it calculates the age after completion of all the fields user get registered successfully.but when registered user trying to update his date of birth his age field is blank please tell me why this happening Also please tell me the javascript function My jsp code is: Code: <%@page import="java.lang.reflect.Array"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@page import="java.util.ArrayList"%> <%@page import="com.udhc.model.City"%> <%@page import="com.udhc.model.User" %> <%@page import="com.udhc.model.Country"%> <%@page import="com.udhc.model.State"%> <%@page import="com.udhc.config.ApplicationConstant"%> <%@page import="org.apache.struts.Globals" %> <%@page import="com.udhc.utility.CommanUtility"%> <%@page import="java.util.HashMap"%> <%@page import="com.udhc.form.UserForm"%> <%@page import="com.udhc.utility.DateUtlity"%> <%@page import="java.util.Calendar"%> <jsp:include page="Header.jsp"></jsp:include> <link type="text/css" href="css/jquery.ui.core.css" rel="stylesheet" /> <link type="text/css" href="css/jquery.ui.datepicker.css" rel="stylesheet" /> <link type="text/css" href="css/jquery.ui.theme.css" rel="stylesheet" /> <link type="text/css" href="css/calendar.css" rel="stylesheet"></link> <script type="text/javascript" language="javascript" src="js/jquery.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.ui.core.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.ui.widget.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.datepicker.js"></script> <script type="text/javascript" language="javascript" src="js/calendar.js"></script> <script type="text/javascript"> <% User user= (User)session.getAttribute(ApplicationConstant.UDHC_USER_MODEL); %> // Array of max days in month in a year and in a leap year function addUser() { if(validate()) { document.forms[0].method = "POST"; document.forms[0].nextStep.value = "addUser"; document.forms[0].action = "User.do"; document.forms[0].submit(); } } function updateUser() { if(validate()) { document.forms[0].method = "POST"; document.forms[0].nextStep.value = "updateUser"; document.forms[0].action = "User.do"; document.forms[0].submit(); } } function ClearOptions(OptionList) { for (x = OptionList.length; x >= 0; x = x - 1) { OptionList[x] = null; } } function AddToOptionList(OptionList, OptionValue, OptionText) { OptionList[OptionList.length] = new Option(OptionText, OptionValue); } } function getSecretQuestion() { var questionId=document.forms[0].secretQuestion.value; if(questionId== "") { alert("Select Secret question"); } else { $ajax({ type: "get", url: "Register.do", error: function(data){alert("Error");} }); } } function finish() { var countryId = document.forms[0].country.value; if(countryId == "") { alert("Please select country."); } else { $.ajax({ type: "get", url: "Register.do", data: "nextStep=getStateListByCountry&country="+countryId, error: function(data) {alert("Error");}, success: function(response) { var stateList = document.forms[0].state; ClearOptions(stateList); AddToOptionList(stateList,"","Select State"); $.each($(response).find("state"), function(i, state) { var stateId = $(state).children("stateId").text(); var stateName = $(state).children("stateName").text(); AddToOptionList(stateList,stateId,stateName); }); } }); } } </script> <% ArrayList<City> cityList =(ArrayList<City>)request.getAttribute("CITY_LIST"); ArrayList<Country> countryList =(ArrayList<Country>)request.getAttribute("COUNTRY_LIST"); ArrayList<State> stateList =(ArrayList<State>)request.getAttribute("STATE_LIST"); %> <div> </div> <input type="hidden" name="<%=org.apache.struts.taglib.html.Constants.TOKEN_KEY %>" value="<bean:write name="<%=Globals.TRANSACTION_TOKEN_KEY%>"/>" /> <div style="float: left;"> <logic:notEmpty name="UPDATE_USER"> <a href="User.do?nextStep=userHome">Back</a> </logic:notEmpty> </div> <div style="width: 700px; margin-left: 100px;" class="border"> <table class="back_img" cellspacing="5" width="100%" height="600"> <tr valign="top"> <td height="10"><h3><u>User Registration</u></h3></td> </tr> <tr valign="top"> <td> <table> <tr> <td> </td> </tr> <!--<tr> <td><b>Name:</b> </td> <td><input type="text" name="firstName" class="textfield"/> <input type="text" name="middleName" class="textfield"/> <input type="text" name="lastName" class="textfield"/></td> </tr> <tr> <td width="200"> </td> <td> First Name Middle Name Last Name</td> </tr>--> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span><b>Gender:</b></td> <td><html:radio property="gender" name="UserForm" value="<%=ApplicationConstant.GENDER_MALE %>" tabindex="1"/>Male <html:radio property="gender" name="UserForm" value="<%=ApplicationConstant.GENDER_FEMALE %>" tabindex="2"/>Female <span style="color:red;font-size:small;visibility: true">*</span> <b>Birth Date: </b> <input type="text" name="dateOfBirth" readonly="readonly" value="<bean:write property="dateOfBirth" name="UserForm"/>" ><a href="#" onClick="setYears(1900, 2013); showCalender(this, 'dateOfBirth');" > <img src="images/calendar.gif"></a> <span style="color:red;font-size:small;visibility: true">*</span><b>Age: </b> <!-- <input type="text" id='idAge' name="age" class="textfield4" ondblclick="closeCalender();calcAge();" tabindex="4" maxlength="3"></input>--> <input type="text" id='idAge' name="age" class="textfield4" onclick="pickDate(month,day,year);" tabindex="4" maxlength="3"></input> </td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span><b>Password:</b></td> <td><html:password name="UserForm" property="userPassword" styleClass="textfield"/></td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span><b>Confirm Password:</b> </td> <td><input type="password" name="confirmPassword" class="textfield" value="<bean:write name="UserForm" property="userPassword"/>"/></td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span><b>Secret Question:</b> </td> <td><select name="secretQuestion" class="selectfield" style="width:220px;"> <option value="">Select secret Question?</option> <% HashMap<String, String> qHash = CommanUtility.getQuestion(); if(session.getAttribute(ApplicationConstant.UDHC_USER_MODEL) != null) { //User user = (User)session.getAttribute(ApplicationConstant.UDHC_USER_MODEL); if(user != null) { for(int i = 1; i <= qHash.size(); i++) { if((i+"").equals(user.getSecretQuestion())) { %> <option value="<%=i %>" selected="selected"><%=qHash.get(i+"") %></option> <% } else { if(qHash.get(i+"") != null) { %> <option value="<%=i %>"><%=qHash.get(i+"") %></option> <% } } } } } else { for(int i = 1; i <= qHash.size(); i++) { if(qHash.get(i+"") != null) { %> <option value="<%=i %>"><%=qHash.get(i+"") %></option> <% } } } %> </select> </td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span><b>Secret Answer:</b> </td> <td><html:text property="secretAnswer" name="UserForm" styleClass="textfield"/></td> </tr> <tr> <td><b>Contact details:</b> </td> <td> </td> </tr> <tr> <td> </td> <td> <table> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span>Address 1:</td> <td><html:text property="address1" name="UserForm" styleClass="textfield1"/></td> </tr> <tr> <td>Address 2:</td> <td><html:text property="address2" name="UserForm" styleClass="textfield1"/></td> </tr> </table> <table> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span>Country: </td> <td> <html:select property="country" name="UserForm" styleClass="selectfield" onchange="javascript:getStateList();"> <html:option value="">Select Country</html:option> <html:optionsCollection name="COUNTRY_LIST" value="countryId" label="name" /> </html:select> </td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span>State:</td> <td> <html:select property="state" name="UserForm" styleClass="selectfield" onchange="javascript:getCityList();"> <html:option value="">Select State</html:option> <html:optionsCollection name="STATE_LIST" value="stateId" label="name" /> </html:select> </td> <td><span style="color:red;font-size:small;visibility: true">*</span>City: </td> <td> <html:select property="cityId" name="UserForm" styleClass="selectfield"> <html:option value="">Select City</html:option> <html:optionsCollection name="CITY_LIST" value="cityId" label="name" /> </html:select> </td> <td>PIN:</td> <td><html:text property="pinCode" name="UserForm" styleClass="textfield"/></td> </tr> <tr> <td>Phone: </td> <td><html:text property="phone" name="UserForm" styleClass="textfield"/></td><td><span style="color:red;font-size:small;visibility: true">*</span>Cell:</td><td><html:text property="cellNo" name="UserForm" styleClass="textfield"/></td> </tr> <tr> <td><span style="color:red;font-size:small;visibility: true">*</span>Email: </td> <td colspan="4"><html:text property="email" name="UserForm" styleClass="textfield1"/></td> </tr> </table> </td> </tr> <tr> <td valign="top"><b>Other Relevant Information:</b></td> <td> <table> <tr> <td>Height:</td> <td><html:text property="height" name="UserForm" styleClass="textfield3"/><b>Cm.</b></td> <td>Weight:</td> <td><html:text property="weight" name="UserForm" styleClass="textfield3"/><b>Kg</b></td> </tr> <tr> <td>Blood Pressu </td> <td><html:text property="bPSystolic" name="UserForm" styleClass="textfield4"/> <html:text property="bPDiastolic" name="UserForm" styleClass="textfield4"/><b>mmHg</b></td> <td>Pulse rate:</td> <td><html:text property="pulseRate" name="UserForm" styleClass="textfield3"/></td> </tr> </table> </td> </tr> <logic:empty name="UPDATE_USER"> <tr> <td> </td> <td align="char" colspan="2" rowspan="2"><a href="javascript:addUser();"><img src="images/Register1.png" border="0"></img></a> <a href="index.jsp"><img src="images/Cancel1.png" border="0"></img></a></td> </tr> </logic:empty> <logic:notEmpty name="UPDATE_USER"> <tr> <td> </td> <td align="char"><a href="javascript:updateUser();"><img src="images/update.png" border="0"></img></a> <a href="User_Home.jsp"><img src="images/Cancel1.png" border="0"></img></a></td> </tr> </logic:notEmpty> </table> </td> </tr> <logic:messagesPresent message="true"> <tr> <td colspan="2" align="center"> <html:messages id="message" message="true"> <div class="error"> <bean:write name="message"/> </div> </html:messages> </td> </tr> </logic:messagesPresent> </div> </table> <table id="calenderTable"> <tbody id="calenderTableHead"> <tr> <td colspan="4" align="center"> <select onChange="showCalenderBody( createCalender(document.getElementById('selectYear').value, this.selectedIndex, false));" id="selectMonth"> <option value="0">Jan</option> <option value="1">Feb</option> <option value="2">Mar</option> <option value="3">Apr</option> <option value="4">May</option> <option value="5">Jun</option> <option value="6">Jul</option> <option value="7">Aug</option> <option value="8">Sep</option> <option value="9">Oct</option> <option value="10">Nov</option> <option value="11">Dec</option> </select> </td> <td colspan="2" align="center"> <select onChange="showCalenderBody(createCalender(this.value, document.getElementById('selectMonth').selectedIndex, false));" id="selectYear"> </select> </td> <td align="center"> <a href="#" onClick="closeCalender();calcAge();"> <font color="#003333" size="+1">X</font> </a> </td> </tr> </tbody> <tbody id="calenderTableDays"> <tr style=""> <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td> <td>Thu</td><td>Fri</td><td>Sat</td> </tr> </tbody> <tbody id="calender"></tbody> </table> <jsp:include page="Footer.jsp"></jsp:include> Hi There, Below is some very basic html/javascript that asks for a user to enter a number in an input text box and then a button is pressed it writes out a line that number of times. It works, but when run in firefox the pages always seems to continue to load... that is, the cursor is continuously that when a page is loading (an arrow with a little circle) and the status bar in the bottom right hand corner seems to be always be at zero. It seems to be something in the for loop as when this is take out it works. Seems to work in IE however? Any ideas? Is this a FireFox thing or am I not terminating the loop properly? Code: <html> <head> <script type="text/javascript" language="javascript"> <!-- function writeloop(){ var noTimes = document.theForm.theAmount.value; for(x=0;x<=noTimes;x++){ document.write("A line!"+"<br />"); } } function cleantext(){ document.theForm.theAmount.value=""; } //--> </script> <title>Write Loop</title> </head> <body> <form name="theForm" action="#"> <input type=button value="Press me" onclick="writeloop();" /> <br /><br /> Enter the amount of times:  <input type=text name="theAmount" value="blah" onfocus="cleantext()"/> </form> </body> Many thanks! Hi all Is there a way to get the image(s) to load into the table after the page has loaded instead of the way I have it now? I have 4 tabs, but I would like the imgs in tabs 2,3,4 to load after page load. Example of how the tabs look. Code: <div class="tabbertab"> <h2>Australia_____</h2> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFCC"> <caption class="highlight_Red">澳洲 Australia </caption> <tr> <td><a href="pages/promotion.html#aus_ACE" rel="nofollow" target="_blank"><img src="pages/images/Pics/AUS/ace.jpg" alt="ACE / ATTC" width="110" height="69" border="0" align="left" class="ozimg_L"/> ...a few more images etc the other tabs look the same. LT Hello , here is my code(which is not working on my problem) i want to remove anchor tag(href="a") will u please help.... Code: <html> <head><title>Welcome to DevForum</title></head> <script language="javascript" type="text/javascript"> function Remove() { var anchor = document.getElementsByTagName("a"); var i; for(i=0;i<anchor.length;i++) { var anc=anchor.item(i); var href=anc.attributes.getNamedItem("href"); if (href.value == "a") { anchor.item(i).attributes.getNamedItem("href").value = ""; } } } </script> <body onload="Remove()"> <h1>Welcome</h1> <a href="b">b</a> <a href="a">a</a> </body> </html> Thanks in Advance.... This script displays a link to a registration/login form that loads in a light box for Joomla. I've been goin nuts trying to figure out how to get this to load on page load with a delay. Anyone know how to get this done? PHP Code: <?php JHTML::_('behavior.mootools'); $document = JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'media/system/css/modal.css'); $document->addScript(JURI::base() . 'media/system/js/modal.js'); $document->addScriptDeclaration("window.addEvent('domready', function() {SqueezeBox.initialize({});});"); $user = & JFactory::getUser(); $uri = JFactory::getURI(); $url = $uri->toString(); $return = base64_encode($url); ?> <div id="lbframeid" style="position:absolute;top:1px;left:1px;height:0px;width:0px;overflow:hidden"> <a href="http://www.wowjoomla.com/"><h1>Joomla Login LightBox powered by WowJoomla.com</h1> </a> </div> <?php if ($user->get('guest')) :?> <a href="<?php echo JRoute::_('index.php?option=com_loginbox')?>" onclick="SqueezeBox.fromElement(this); return false;" rel="{handler: 'iframe', size: {x: 660, y: 500}}"><?php echo JText::_('SIGNUP_LOGIN')?></a> <?php else: ?> <?php echo JText::sprintf( 'HINAME', $user->get('name') ); ?> <br> <a href="javascript:void(0);" onclick="LB_onLogout(); return false;"><?php echo JText::_('LOGOUT')?></a> <?php endif; ?> <script type="text/javascript"> function LB_onLogout() { var form = new Element('form'); form.setProperty('method', 'POST'); form.setProperty('target', '_self'); form.setProperty('action', 'index.php'); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'option'); input.setProperty('value', 'com_user'); form.appendChild(input); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'task'); input.setProperty('value', 'logout'); form.appendChild(input); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'return'); input.setProperty('value', '<?php echo $return; ?>'); form.appendChild(input); $E('body').appendChild(form); form.submit(); } </script> How to modify the script so that after from refreshing after set time it should refresh for only x number of time. Say the page should reload after 300*1000 (time/seconds) for say 4 times (number). After the page has refresh 4 times, it should not refresh again. <HTML> <HEAD> <script><!-- function doLoad() { setTimeout( "refresh()", 300*1000 ); } function refresh() { window.location.reload( true ); } //--></script> </HEAD> <BODY BGCOLOR=#FFFFFF onload="doLoad()"> I'm working on a site built through Squarespace, and I've run into some limitations. They've told me it's possible to build a Javascript to pull specific images from one page's journal entries and place them (with links to the entry) on other pages. Can somebody send me in the right direction on how I would do this? Basically I want to find a most recent posting tagged with a specific category, find the file file path of it's related image, and make that appear on the page that my javascript is on. Hi gents, I am trying to figure out, how to play a video file saved on the server, displayed as a hyperlink from the file manager created in JavaScript? The outcome should be following: When a file name (video.avi) clicked in JavaScript file manager, the server will open a page with the embed Windows Media Player (player.php) and it will start playing the clicked video file? Any suggestions? Code of the JavaScript file manager Code: <? /* Start Directory - To list the files contained within the current directory enter '.', otherwise enter the path to the directory you wish to list. The path must be relative to the current directory. */ $startdir = '.'; /* Show Thumbnails? - Set to true if you wish to use the scripts auto-thumbnail generation capabilities. This requires that GD2 is installed. */ $showthumbnails = true; /* Show Directories - Do you want to make subdirectories available? If not set this to false */ $showdirs = true; /* Force downloads - Do you want to force people to download the files rather than viewing them in their browser? */ $forcedownloads = false; /* Hide Files - If you wish to hide certain files or directories then enter their details here. The values entered are matched against the file/directory names. If any part of the name matches what is entered below then it is now shown. */ $hide = array( 'dlf', 'index.php', 'Thumbs', '.htaccess', '.htpasswd' ); /* Show index files - if an index file is found in a directory to you want to display that rather than the listing output from this script? */ $displayindex = false; /* Allow uploads? - If enabled users will be able to upload files to any viewable directory. You should really only enable this if the area this script is in is already password protected. */ $allowuploads = false; /* Overwrite files - If a user uploads a file with the same name as an existing file do you want the existing file to be overwritten? */ $overwrite = false; /* Index files - The follow array contains all the index files that will be used if $displayindex (above) is set to true. Feel free to add, delete or alter these */ $indexfiles = array ( 'index.html', 'index.htm', 'default.htm', 'default.html' ); /* File Icons - If you want to add your own special file icons use this section below. Each entry relates to the extension of the given file, in the form <extension> => <filename>. These files must be located within the dlf directory. */ $filetypes = array ( 'png' => 'jpg.gif', 'jpeg' => 'jpg.gif', 'bmp' => 'jpg.gif', 'jpg' => 'jpg.gif', 'gif' => 'gif.gif', 'zip' => 'archive.png', 'rar' => 'archive.png', 'exe' => 'exe.gif', 'setup' => 'setup.gif', 'txt' => 'text.png', 'htm' => 'html.gif', 'html' => 'html.gif', 'fla' => 'fla.gif', 'swf' => 'swf.gif', 'xls' => 'xls.gif', 'doc' => 'doc.gif', 'sig' => 'sig.gif', 'fh10' => 'fh10.gif', 'pdf' => 'pdf.gif', 'psd' => 'psd.gif', 'rm' => 'real.gif', 'mpg' => 'video.gif', 'mpeg' => 'video.gif', 'mov' => 'video2.gif', 'avi' => 'video.gif', 'eps' => 'eps.gif', 'gz' => 'archive.png', 'asc' => 'sig.gif', ); /* That's it! You are now ready to upload this script to the server. Only edit what is below this line if you are sure that you know what you are doing! */ error_reporting(0); if(!function_exists('imagecreatetruecolor')) $showthumbnails = false; $leadon = $startdir; if($leadon=='.') $leadon = ''; if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/'; $startdir = $leadon; if($_GET['dir']) { //check this is okay. if(substr($_GET['dir'], -1, 1)!='/') { $_GET['dir'] = $_GET['dir'] . '/'; } $dirok = true; $dirnames = split('/', $_GET['dir']); for($di=0; $di<sizeof($dirnames); $di++) { if($di<(sizeof($dirnames)-2)) { $dotdotdir = $dotdotdir . $dirnames[$di] . '/'; } if($dirnames[$di] == '..') { $dirok = false; } } if(substr($_GET['dir'], 0, 1)=='/') { $dirok = false; } if($dirok) { $leadon = $leadon . $_GET['dir']; } } if($_GET['download'] && $forcedownloads) { $file = str_replace('/', '', $_GET['download']); $file = str_replace('..', '', $file); if(file_exists($leadon . $file)) { header("Content-type: application/x-download"); header("Content-Length: ".filesize($leadon . $file)); header('Content-Disposition: attachment; filename="'.$file.'"'); readfile($leadon . $file); die(); } } if($allowuploads && $_FILES['file']) { $upload = true; if(!$overwrite) { if(file_exists($leadon.$_FILES['file']['name'])) { $upload = false; } } if($upload) { move_uploaded_file($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']); } } $opendir = $leadon; if(!$leadon) $opendir = '.'; if(!file_exists($opendir)) { $opendir = '.'; $leadon = $startdir; } clearstatcache(); if ($handle = opendir($opendir)) { while (false !== ($file = readdir($handle))) { //first see if this file is required in the listing if ($file == "." || $file == "..") continue; $discard = false; for($hi=0;$hi<sizeof($hide);$hi++) { if(strpos($file, $hide[$hi])!==false) { $discard = true; } } if($discard) continue; if (@filetype($leadon.$file) == "dir") { if(!$showdirs) continue; $n++; if($_GET['sort']=="date") { $key = @filemtime($leadon.$file) . ".$n"; } else { $key = $n; } $dirs[$key] = $file . "/"; } else { $n++; if($_GET['sort']=="date") { $key = @filemtime($leadon.$file) . ".$n"; } elseif($_GET['sort']=="size") { $key = @filesize($leadon.$file) . ".$n"; } else { $key = $n; } $files[$key] = $file; if($displayindex) { if(in_array(strtolower($file), $indexfiles)) { header("Location: $file"); die(); } } } } closedir($handle); } //sort our files if($_GET['sort']=="date") { @ksort($dirs, SORT_NUMERIC); @ksort($files, SORT_NUMERIC); } elseif($_GET['sort']=="size") { @natcasesort($dirs); @ksort($files, SORT_NUMERIC); } else { @natcasesort($dirs); @natcasesort($files); } //order correctly if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);} if($_GET['order']=="desc") {$files = @array_reverse($files);} $dirs = @array_values($dirs); $files = @array_values($files); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Directory Listing of <?=dirname($_SERVER['PHP_SELF']).'/'.$leadon;?></title> <link rel="stylesheet" type="text/css" href="dlf/styles.css" /> <? if($showthumbnails) { ?> <script language="javascript" type="text/javascript"> <!-- function o(n, i) { document.images['thumb'+n].src = 'dlf/i.php?f='+i; } function f(n) { document.images['thumb'+n].src = 'dlf/trans.gif'; } //--> </script> <? } ?> </head> <body> <div id="container"> <h1>Directory Listing of <?=dirname($_SERVER['PHP_SELF']).'/'.$leadon;?></h1> <div id="breadcrumbs"> <a href="<?=$_SERVER['PHP_SELF'];?>">home</a> <? $breadcrumbs = split('/', $leadon); if(($bsize = sizeof($breadcrumbs))>0) { $sofar = ''; for($bi=0;$bi<($bsize-1);$bi++) { $sofar = $sofar . $breadcrumbs[$bi] . '/'; echo ' > <a href="'.$_SERVER['PHP_SELF'].'?dir='.urlencode($sofar).'">'.$breadcrumbs[$bi].'</a>'; } } $baseurl = $_SERVER['PHP_SELF'] . '?dir='.$_GET['dir'] . '&'; $fileurl = 'sort=name&order=asc'; $sizeurl = 'sort=size&order=asc'; $dateurl = 'sort=date&order=asc'; switch ($_GET['sort']) { case 'name': if($_GET['order']=='asc') $fileurl = 'sort=name&order=desc'; break; case 'size': if($_GET['order']=='asc') $sizeurl = 'sort=size&order=desc'; break; case 'date': if($_GET['order']=='asc') $dateurl = 'sort=date&order=desc'; break; default: $fileurl = 'sort=name&order=desc'; break; } ?> </div> <div id="listingcontainer"> <div id="listingheader"> <div id="headerfile"><a href="<?=$baseurl . $fileurl;?>">File</a></div> <div id="headersize"><a href="<?=$baseurl . $sizeurl;?>">Size</a></div> <div id="headermodified"><a href="<?=$baseurl . $dateurl;?>">Last Modified</a></div> </div> <div id="listing"> <? $class = 'b'; if($dirok) { ?> <div><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($dotdotdir);?>" class="<?=$class;?>"><img src="dlf/dirup.png" alt="Folder" /><strong>..</strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($dotdotdir));?></a></div> <? if($class=='b') $class='w'; else $class = 'b'; } $arsize = sizeof($dirs); for($i=0;$i<$arsize;$i++) { ?> <div><a href="<?=$_SERVER['PHP_SELF'].'?dir='.urlencode($leadon.$dirs[$i]);?>" class="<?=$class;?>"><img src="dlf/folder.png" alt="<?=$dirs[$i];?>" /><strong><?=$dirs[$i];?></strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$dirs[$i]));?></a></div> <? if($class=='b') $class='w'; else $class = 'b'; } $arsize = sizeof($files); for($i=0;$i<$arsize;$i++) { $icon = 'unknown.png'; $ext = strtolower(substr($files[$i], strrpos($files[$i], '.')+1)); $supportedimages = array('gif', 'png', 'jpeg', 'jpg'); $thumb = ''; if($showthumbnails && in_array($ext, $supportedimages)) { $thumb = '<span><img src="dlf/trans.gif" alt="'.$files[$i].'" name="thumb'.$i.'" /></span>'; $thumb2 = ' onmouseover="o('.$i.', \''.urlencode($leadon . $files[$i]).'\');" onmouseout="f('.$i.');"'; } if($filetypes[$ext]) { $icon = $filetypes[$ext]; } $filename = $files[$i]; if(strlen($filename)>43) { $filename = substr($files[$i], 0, 40) . '...'; } $fileurl = $leadon . $files[$i]; if($forcedownloads) { $fileurl = $_SESSION['PHP_SELF'] . '?dir=' . urlencode($leadon) . '&download=' . urlencode($files[$i]); } ?> <div><a href="<?=$fileurl;?>" class="<?=$class;?>"<?=$thumb2;?>><img src="dlf/<?=$icon;?>" alt="<?=$files[$i];?>" /><strong><?=$filename;?></strong> <em><?=round(filesize($leadon.$files[$i])/1024);?>KB</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$files[$i]));?><?=$thumb;?></a></div> <? if($class=='b') $class='w'; else $class = 'b'; } ?></div> <? if($allowuploads) { $phpallowuploads = (bool) ini_get('file_uploads'); $phpmaxsize = ini_get('upload_max_filesize'); $phpmaxsize = trim($phpmaxsize); $last = strtolower($phpmaxsize{strlen($phpmaxsize)-1}); switch($last) { case 'g': $phpmaxsize *= 1024; case 'm': $phpmaxsize *= 1024; } ?> <div id="upload"> <div id="uploadtitle"><strong>File Upload</strong> (Max Filesize: <?=$phpmaxsize;?>KB)</div> <div id="uploadcontent"> <? if($phpallowuploads) { ?> <form method="post" action="<?=$_SERVER['PHP_SELF'];?>?dir=<?=urlencode($leadon);?>" enctype="multipart/form-data"> <input type="file" name="file" /> <input type="submit" value="Upload" /> </form> <? } else { ?> File uploads are disabled in your php.ini file. Please enable them. <? } ?> </div> </div> <? } ?> </div> </div> <div></div> </body> </html> Code of the PHP page with the embed Windows Media Player (player.php) Code: <html> <head> <title>Player</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <body> </head> <OBJECT id=mediaPlayer classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6 width=400 height=300 type=application/x-oleobject VIEWASTEXT><PARAM NAME="AutoSize" VALUE="1"><PARAM NAME="DisplaySize" VALUE="2"><PARAM NAME="url" VALUE=""><PARAM NAME="autoStart" VALUE="true"><PARAM NAME="uiMode" VALUE="mini"> <embed id="mediaPlayer" name="mediaPlayer" width="400" height="300" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="video.avi" autostart="true" showstatusbar="0" showcontrols="1" autosize="1" displaysize="4"></embed> </OBJECT> </body> </html> Please note that video.avi in player.php will be variable (name of the video file chosen by user and clicked). Many thanks for help. ZizaX. Hi, I'm very new to Javascript and I'm stuck. I am trying to create a js script that will prompt the user for a times table (example the 5 times table, the 7 times table, etc.) & prompt the user for 2 more values; the 'start' number and 'end' number. So there would be 3 numbers total the user must input. The script should present a 'warning' message if the user inputs letters or negative numbers. I have come very close to getting it too work but can't quite get past the last hurdle. Upon entering the 3 numbers, the output should look similar to this: (the 5 times table starting with 1 and ending with 12) The 5 times table 5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 5 * 6 = 30 5 * 7 = 35 5 * 8 = 40 5 * 9 = 45 5 * 10 = 50 5 * 11 = 55 5 * 12 = 60 I have placed the js script code on pastebin.com and below. The pastebin link is: http://pastebin.com/2NZPiFH9 Code: function writeTimesTable(timesTable, timesByStart, timesByEnd) { for (;timesByStart <= timesByEnd; timesByStart++) { document.write(timesTable + " * " + timesByStart + " = " + timesByStart * timesTable + "<br>"); } } var timesTable; while ( (timesTable = prompt("Enter the first number in the times table. Enter -1 to exit.", -1)) != -1) { while (isNaN(timesTable) == true) { timesTable = prompt(timesTable + " is not a valid number, please retry.",-1); } if (timesTable == -1) { break; } document.write("<br>The " + timesTable + " times table<br>"); writeTimesTable(timesTable,1,12); } First off I didn't know whether to post this here or in the PHP section since it deals with both, but mostly JS. I have a PHP scraper that scrapes the job title, company name and location from a website and stores them in separate arrays. These values are then extracted out one at a time from the array and stored into a string, that is then passed to a Google Maps API. I can make this successfully happen once, the thing is I need to do it multiple times. I have an idea on what I should do but don't really know how to implement it (correctly). The idea I had was to create a function in the JavaScript section that accepts three values from PHP. This function would be called in my PHP for loop that extracts the values from the array into a string. The thing that confuses me is that the Map function is called via <body onLoad="initialize()">. Here's the link to my code Hello. My goal is to load the JS for a specific element before displaying that element. I integrated a third part script, and it works well. I set the timer he The JS is in my heading as <script type="text/javascript" src="countdownpro.js"></script> About mid-body I have: <span id="countdown1">2010-07-20 00:00:00 GMT+00:00</span> which allows for the setting of a target date to countdown to. When the page first loads it shows the above long format target time, until the js/meta tags kick in to modify it to just show the actual countdown as 00:00:00. I have attached countdownpro.js to this post. I tried shifting the function CD_Init() to the top of the script, and also appended it inline with the .html. I tried setting the big external script to "defer", but neither arrangement worked. I also tried placing the src file right at the top. I appreciate your help. Hi All, Im new to this forum...need some of your help and advice. I have a js code like this : <script type="text/javascript"> <!-- var sipPos = 0; $(document).ready(function() { $("#panel-tab").click(function(e) { //if(autoTimer) clearTimeout(autoTimer); //autoTimer = null; e.preventDefault(); $("#panel").animate({ left: sipPos }, 1764, 'linear', function() { if(sipPos == 0) { sipPos = -856; } else { sipPos = 0; } }); }); }); --> </script> what it does is that it hide and show a panel by slidint it to the left. But my client want that on page load the panel opens automatically for about 2-3 seconds just to let users know that its here. So ive written this : <script type="text/javascript"> <!-- var sipPos = 0; $(document).ready(function() { var autoTimer = null; autoTimer = setTimeout(function(){ $("#panel").animate({ left: sipPos }); autoTimer = setTimeout(function(){ $("#panel").animate({ left: sipPos = -856 }); }, 2000); },1000); $("#panel-tab").click(function(e) { //if(autoTimer) clearTimeout(autoTimer); //autoTimer = null; e.preventDefault(); $("#panel").animate({ left: sipPos }, 1764, 'linear', function() { if(sipPos == 0) { sipPos = -856; } else { sipPos = 0; } }); }); }); --> </script> But when the panel finished showing the button to open it again doesn't work...any help please..really urgent. thks //Sam 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 Hi guys, I am trying to insert the following call into my page; Code: <script type="text/javascript" defer="true"> $('#query').autocomplete({ serviceUrl:'service/autocomplete.ashx', minChars:1, delimiter: /(,|;)\s*/, // regex or character maxHeight:400, width:250, deferRequestBy: 0, //miliseconds params: { country:'Yes' }, //aditional parameters // local autosugest options: lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values }); </script> It works fine in all browsers except ie(6,7,8) Code: Internet Explorer can not open website. Operation Aborted. I understand it is caused by the jquery autocomplete function loading before the page / DOM has fully loaded. I tried adding Defer="true" to the script however this doesn't seem to work. Could someone please tell me what i must add to the script so that it loads after the dom has fully loaded? Thanks guys George Hi guys. I've made a html file with three lists to populate different pages of my site. Then i've called the html with SSI. let me show the code the HTML with the list's Code: <div id="list_box"> <ul class="list"> <li><a href="#">item01</a></li> <li><a href="#">item02</a></li> <li><a href="#">item03</a></li> <li><a href="#">item04</a></li> <li><a href="#">item05</a></li> </ul> </div> <div id="list_box"> <ul class="list"> <li><a href="#">item06</a></li> <li><a href="#">item07</a></li> <li><a href="#">item08</a></li> <li><a href="#">item09</a></li> <li><a href="#">item10</a></li> </ul> </div> <div id="list_box"> <ul class="list"> <li><a href="#">item11</a></li> <li><a href="#">item12</a></li> <li><a href="#">item13</a></li> <li><a href="#">item14</a></li> <li><a href="#">item15</a></li> </ul> </div> the HTML with the list loaded Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- #list_box { height:100%; width: 100%; padding-top: 15px; padding-left: 30px; padding-right: 30px; padding-bottom: 20px; background-color: #cccccc; overflow: hidden; } ul.list li { list-style-type: none; text-align: left; text-decoration: none; } .list a:link, .list a:visited { font-family: "Courier New", Courier, monospace; font-size: 12px; line-height: 15px; color: #036; text-decoration: none; text-align: left; font-weight: bold; font-style: normal; } .list a:hover{ font-family: "Courier New", Courier, monospace; font-size: 12px; line-height: 15px; color: #ffffff; text-decoration: none; text-align: left; font-weight: bold; font-style: normal; } --> </style> </head> <body> <div id="list_box"> <!--#include file="list.html" --> </div> </body> </html> the zip with the sample I've made load_external.zip I wanted to ask how can I make an item from the list's to have a different css in the html with the loaded list's. because in each page one of the items (that are all buttons) will be up or should I say active. can someone tell me how can I do this please. Maybe with javascript? thanks in advance |