JavaScript - Using External Html Code In A Javascript File.
I have some HTML that I want to put in a Javascript file and reference the HTML through external Javascript file.
So I have my page, example.html Code: <html> <head></head> <body> <script type="text/javascript src="../js/external.js"> </script> </body> </html> external.js Code: document.write("<p class="txt_medium style4"> example.com<br />101 Street St.<br />City, ST, ZIP</p><p class="txt_medium style4">"The Best website." </p>"); The above code is all on one line, but is not displaying on the page. PHP is out of the question too (_._) Any thoughts? Similar TutorialsCan you place java code in an external javascript file (.js). For example can I do the following in my xx.js file. $(document).ready(function(){ <% execute some java code here %> ...execute some javascript code here... }) Can I do the above? Another question ... I know <% %> is to execute java code inside html. But what does <%-- - -%> mean? Thanks for any help. Hi, i have a question, is JavaScript can read an external file? i have an ear file, can it read external file without the external file compile together in the ear file? can we do so? First, this is my first time coding anything seriously. I've only dabbled here and there, but no more. Any and all tips are appreciated. I have a program that's designed to calculate total enemy health. Its does this by taking user input on the level and enemy name. The enemy level input determines the base health stat. The enemy name determines the percent multiplier. This all runs on an onClick() event. I originally had this all in my <head> in my html code. It ended up being more code than I expected. So i made it an external javascript file. I did remove the <script></script> tags, I believe I have the file properly linked using the src attribute. I'm at my wits end. This is my second day of trying. So here is the javascript code. Code: // JavaScript Document var series; var index; var indexValue; var base; var distance; var sequence; var enemyLv; var enemyPct; var enemyHp; var vOneFive; var wrongAlert; var enemyList; var enemyName; var enemyInput; var enemyLevel; var a = enemyLEVEL(); var b = enemyPCT(); var totalHp = a * b; //calculates enemyHp and enemyPct function calc(enemyHp, enemyPct) { a = enemyLEVEL(); b = enemyPCT(); totalHp = a * b; if(a && b !== -1){ document.getElementById('enemyTotalHp').innerHTML = totalHp; } else{ alert(wrong); } } //determines base stat for enemyHp function enemyLEVEL(enemyHp){ enemyLv = document.getElementById('enemyLevel').value; var enemyLvValue = enemyLv * 1; wrongAlert = "BURGA!"; //determines which HP sequence to run if(enemyLvValue <= 5){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '12345'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 70; distance = 13; sequence = base + (indexValue * distance); enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 10){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '5678910'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 122; distance = 24.8; sequence = base + (indexValue) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 15){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '101112131415'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 246; distance = 50; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 20){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '151617181920'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 496; distance = 129.8; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 45){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '2021222324252627282930313233343536373839404142434445'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 1145; distance = 120; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 50){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '454647484950'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 4145; distance = 133; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if (enemyLvValue <= 75){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '5051525354555657585960616263646566676869707172737475'; index = series.lastIndexOf(enemyLvValue); indexValue = index * 1; base = 4810; distance = 75; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if (enemyLvValue <= 99){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series = '75767778798081828384858687888990919293949596979899'; index = series.lastIndexOf(enemyLvValue); indexValue = index * 1; base = 6685; distance = 70; sequence = base + ((indexValue)/2) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 110){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series ='100101102103104105106107108109110'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 8435; distance = 70; sequence = base + ((indexValue)/3) * distance; enemyHp = sequence; return enemyHp; } else if(enemyLvValue <= 170){ enemyLv = document.getElementById('enemyLevel').value; enemyLvValue = enemyLv * 1; series ='110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170'; index = series.indexOf(enemyLvValue); indexValue = index * 1; base = 9130; distance = 70; sequence = base + ((indexValue)/3) * distance; enemyHp = sequence; return enemyHp; } else{ alert(wrongAlert); } } //determines enemyPct variable function enemyPCT(enemyPct){ enemyInput = document.getElementById('enemyUser').value; enemyName = enemyInput; enemyList = new Array(); enemyList[1] = "Vahra Go Vahra Delsaban Golmoro Goshin Fulyen Curtz SEED-Guardian (Tw) Special Ops (Assault) Bysha type-Koh21 Bysha type-Otsu32 Gohma Dilla Gohma Methna GSM-05 Seeker GSM-05B Bomalta GSM-05M Tirentos YG-01K BUGGE YG01U BUGGES YG-01Z BUG Deljaban Orcdillan Sendillan";//100% hp // enemyList[2] = "Ageeta Sageeta Rogue Wikko Special Ops (Vobis)"; //60% hp // enemyList[3] = "Pannon Bel Pannon Galdeen Kudetob Nava Ludda Naval Zoona Shagreece Lapucha Polty Badia Go Bajilla"; //70% hp // enemyList[4] = "Armed Servant (Obme) Armed Servant (Ozuna) Distova Volfu Olgohmon Bul Buna";//90% hp // enemyList[5] = "Koltova Kakwane Ollaka Rappy Polec AMF Heavy Infantry Armed Servant (Basta) SEED-Guardian (Kn) Delp Slami";//130%hp // enemyList[6] = "Booma Go Booma Jigo Booma Jishagara Vanda Vanda Merha Vanda Orga Rogue (Ogg) SEED-Guardian (Sa)";//150%hp // enemyList[7] = "Rogue (Jasse) Rogue Mazz Special Ops (Kanohne) Special Ops (Solda)";//180%hp // enemyList[8] = "Komazli Bead Groode Dilla Griena Grinna Bete C";//200%hp // enemyList[9] = "Bal Soza Gaozoran";//230%hp; // enemyList[10] = "Shinowa Hidoki" ;//250% hp // enemyList[11] = "Jaggo Jaggo Acte Jaggo Amure Jaggo Sonichi Zamvapas Galvapas Do Vol No Vol";//260% hp // enemyList[12] = "Mizura Gainozeros Grass Assassin Ubakrada Rappy Rappy Amure Rappy Latan Rappy Noel Rappy Paska";//300% hp // enemyList[13] = "Kamatoze Bafal Bragga";//320% hp // enemyList[14] = "Jarba Polavohra Hiru Vol Delnadian SEED-Ardite Zasharogan Lutus Jigga Orgdus Svaltus";//350% hp // enemyList[15] = "Tengohg Bil De Melan Bil De Vear Drua Gohra Kog Nadd Dilnazen Jusnagun SEED-Argine SEED-Vance SEED-Vitace Ryugtass";//400% hp // enemyList[16] = "Carriguine SEED-Venas";//450% hp // enemyList[17] = "Rappy Gugg Renvolt Magashi Grinna Bete S";//500% hp // enemyList[18] = "Rappy Igg";//550% hp // enemyList[19] = "Darbelan Alfort Tylor";//600% hp // enemyList[20] = "Kagajibari";//630% hp // enemyList[21] = "Gol Dova";//650% hp // enemyList[22] = "Zoal Goug"; //700% hp // enemyList[23] = "De Rol Le";//1000% hp // enemyList[24] = "SEED-Magashi";//1100% hp // enemyList[25] = "Alterazgohg Onmagoug";//1350% hp // enemyList[26] = "Adahna Dimmagolus Dark Falz";//1450% hp // enemyList[27] = "De Ragan Magas Maggahna";//1500% hp // enemyList[28] = "Dulk Fakis Mother Brain";//1650% hp // enemyList[29] = "De Ragnus";//1720% hp var one = enemyList[1]; var two = enemyList[2]; var three = enemyList[3]; var four = enemyList[4]; var five = enemyList[5]; var six = enemyList[6]; var seven = enemyList[7]; var eight = enemyList[8]; var nine = enemyList[9]; var ten = enemyList[10]; var eleven = enemyList[11]; var twelve = enemyList[12]; var thirteen = enemyList[13]; var fourteen = enemyList[14]; var fifteen = enemyList[15]; var sixteen = enemyList[16]; var seventeen = enemyList[17]; var eighteen = enemyList[18]; var nineteen = enemyList[19]; var twenty = enemyList[20]; var twentyone = enemyList[21]; var twentytwo = enemyList[22]; var twentythree = enemyList[23]; var twentyfour = enemyList[24]; var twentyfive = enemyList[25]; var twentysix = enemyList[26]; var twentyseven = enemyList[27]; var twentyeight = enemyList[28]; var twentynine = enemyList[29]; // var indexOne = one.indexOf(enemyName); var indexTwo = two.indexOf(enemyName); var indexThree = three.indexOf(enemyName); var indexFour = four.indexOf(enemyName); var indexFive = five.indexOf(enemyName); var indexSix = six.indexOf(enemyName); var indexSeven = seven.indexOf(enemyName); var indexEight = eight.indexOf(enemyName); var indexNine = nine.indexOf(enemyName); var indexTen = ten.indexOf(enemyName); var indexEleven = eleven.indexOf(enemyName); var indexTwelve = twelve.indexOf(enemyName); var indexThirteen = thirteen.indexOf(enemyName); var indexFourteen = fourteen.indexOf(enemyName); var indexFifteen = fifteen.indexOf(enemyName); var indexSixteen = sixteen.indexOf(enemyName); var indexSeventeen = seventeen.indexOf(enemyName); var indexEighteen = eighteen.indexOf(enemyName); var indexNineteen = nineteen.indexOf(enemyName); var indexTwenty = twenty.indexOf(enemyName); var indexTwentyOne = twentyone.indexOf(enemyName); var indexTwentyTwo = twentytwo.indexOf(enemyName); var indexTwentyThree = twentythree.indexOf(enemyName); var indexTwentyFour = twentyfour.indexOf(enemyName); var indexTwentyFive = twentyfive.indexOf(enemyName); var indexTwentySix = twentysix.indexOf(enemyName); var indexTwentySeven = twentyseven.indexOf(enemyName); var indexTwentyEight = twentyeight.indexOf(enemyName); var indexTwentyNine = twentynine.indexOf(enemyName); // var test = "YOU CAN DO IT LITTLE NICKY! BITE HIS ****ING HEAD OFF!"; // if(indexOne != -1){ var enemyPctValue = 1; enemyPct = enemyPctValue; return enemyPct; } // else if(indexTwo != -1){ var enemyPctValue = 0.6; enemyPct = enemyPctValue; return enemyPct; } // else if(indexThree != -1){ var enemyPctValue = 0.7; enemyPct = enemyPctValue; return enemyPct; } // else if(indexFour != -1){ var enemyPctValue = 0.9; enemyPct = enemyPctValue; return enemyPct; } // else if(indexFive != -1){ var enemyPctValue = 1.3; enemyPct = enemyPctValue; return enemyPct; } // else if(indexSix != -1){ var enemyPctValue = 1.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexSeven != -1){ var enemyPctValue = 1.8; enemyPct = enemyPctValue; return enemyPct; } else if(indexEight != -1){ var enemyPctValue = 2; enemyPct = enemyPctValue; return enemyPct; } else if(indexNine != -1){ var enemyPctValue = 2.3; enemyPct = enemyPctValue; return enemyPct; } else if(indexTen != -1){ var enemyPctValue = 2.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexEleven != -1){ var enemyPctValue = 2.6; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwelve != -1){ var enemyPctValue = 3; enemyPct = enemyPctValue; return enemyPct; } else if(indexThirteen != -1){ var enemyPctValue = 3.2; enemyPct = enemyPctValue; return enemyPct; } else if(indexFourteen != -1){ var enemyPctValue = 3.5; enemyPct = enemyPctValue; return enemyPct; } else if (indexFifteen != -1){ var enemyPctValue = 4; enemyPct = enemyPctValue; return enemyPct; } else if(indexSixteen != -1){ var enemyPctValue = 4.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexSeventeen != -1){ var enemyPctValue = 5; enemyPct = enemyPctValue; return enemyPct; } else if(indexEighteen != -1){ var enemyPctValue = 5.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexNineteen != -1){ var enemyPctValue = 6; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwenty != -1){ var enemyPctValue = 6.3; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyOne != -1){ var enemyPctValue = 6.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyTwo != -1){ var enemyPctValue = 7; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyThree != -1){ var enemyPctValue = 10; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyFour != -1){ var enemyPctValue = 11; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyFive != -1){ var enemyPctValue = 13.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentySix != -1){ var enemyPctValue = 14.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentySeven != -1){ var enemyPctValue = 15; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyEight != -1){ var enemyPctValue = 16.5; enemyPct = enemyPctValue; return enemyPct; } else if(indexTwentyNine != -1){ var enemyPctValue = 17.2; enemyPct = enemyPctValue; return enemyPct; } else{ alert(enemyName); } } and this is the html code 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>PSUpedia Enemy HP Calculator</title> <script type="text/javascript" src="hp_calc.js"> </script> </head> <body> <form> Enemy Level: <input type="text" id="enemyLevel"></br> Enemy Name: <input type="text" id="enemyUser"></br> <p>EnemyHp: <b id="enemyTotalHp"> </b></p></br> <input type="button" value="CLICK!" onClick="calc();"> </form> </body> </html> Hi I have 2 external javascript files added in the head section of a html file but neither will work. However, if i place the javascript code in the html file it work. I'm lost and need help. Could it be the onload function
Code: <body onload="showCookies(); startBanner();"> Hi people, I would like to make the following thing: Load a random file, from a xml list, into a div. I've made a scheme where I show what I was trying to make, but I don't know how to make it. I would like to load into a div a random HTML file, loaded from a XML. Does anyone knows an similar example or can tell me how's possible to do this, please? is it better to do with Javascript ? thanks for the attention guys Hi, I have a external file for example abc.js ,in this abc.js file no functions ,it contains some scripting,i want to call the scripting file though html I use the code <script type="text/javascript src="abc.js"></script> in the header file but i want it in a href tag any clues really helpful. thankyou all. Hello, I am in situation where I need a code to redirect a HTML page to new location (Static HTML/Dynamic Web page) however the challenge is that I can not use usual JavaScript Redirect code due to restriction that we can't execute any code/script under body tag. I found that this can be done using an external JS file however I am not able to achieve this. I need the code to be generic so we can apply the same JS file to any page. However, I want the new window to open over the previous one versus opening a second new window. Can someone help me out in this? OK, There's a script on my site that's included like <script src='somePHPfile.php?params... etc It generates an image with some text in it and a few links. When I click 'view source' it just comes up with the <script> tags and nothing else. In Firefox, if I right click on the actual image and go to this frame > view source, I can see everything it's doing. Is there some way I can access this code with Javascript/jquery? I've tried html/dom parsers, etc. with no luck. this is my first time attempting this operation. I want to take some javascript out of my html. here is the original: Code: <!--div#9begin--><div style="float: left; height: 166px; width: 1px;"> <img alt="" src="images/border_short_vert.png" height="169" width="1" /> </div><!--div#9end--> <!--div#10begin--><div style="width: 225px; height: 155px; float: left; height: 16px; background-color: #000000; color: #FFFFFF; margin-left: 0px; margin-bottom: 0px; font-size: small; padding-left: 0px;"> <img alt="" src="images/news.png" height="16" width="222" /><!--div#11begin--><div style="width: 225px; height: 155px; float: left;"></div><!--div#11end--> <script type="text/javascript">// <![CDATA[if(document.layers){document.write('<ilayer id="ns4div" width="'+swidth+'" height="'+sheight+'" bgcolor='+sbcolor+'><div id="ns4div1" width="'+swidth+'" height="'+sheight+'" onmouseover="sspeed=0;" onmouseout="sspeed=rspeed"></div></ilayer>')} if(document.getElementById||document.all){document.write('<div style="position:relative;overflow:hidden;width:'+swidth+'px;height:'+sheight+'px;clip:rect(0 '+swidth+'px '+sheight+'px 0);background-color:'+sbcolor+';" onmouseover="sspeed=0" onmouseout="sspeed=rspeed"><div id="iens6div" style="position:relative;width:'+swidth+'px;"></div></div>');} // ]]> </script> </div><!--div#10end--> and here's my attempt: Code: <div style="width: 225px; height: 155px; float: left; height: 16px; background-color: #000000; color: #FFFFFF; margin-left: 0px; margin-bottom: 0px; font-size: small; padding-left: 0px;"> <img alt="" src="images/news.png" height="16" width="222" /><script type="text/javascript" src="docwrite.js"></script> <div style="width: 225px; height: 155px; float: left;"></div> </div> along with my js: Code: if(document.layers) {document.write('<ilayer id="ns4div" width="'+swidth+'" height="'+sheight+'" bgcolor='+sbcolor+'><div id="ns4div1" width="'+swidth+'" height="'+sheight+'" onmouseover="sspeed=0;" onmouseout="sspeed=rspeed"></div></ilayer>')} if(document.getElementById||document.all) {document.write('<div style="position:relative;overflow:hidden;width:'+swidth+'px;height:'+sheight+'px;clip:rect(0 '+swidth+'px '+sheight+'px 0);background-color:'+sbcolor+';" onmouseover="sspeed=0" onmouseout="sspeed=rspeed"> <div id="iens6div" style="position:relative;width:'+swidth+'px;"></div></div>');} what is the problem? Have I not performed the extraction properly? I have a Java Script that displays a Daily Affirmation on a webpage from an array of 365 Affirmations within the same html webpage file. This makes the html file size way too large. So I would like for the java script to read the array from an external text file on the same website server. Please provide me the Code to insert within my script which will read the array from an external text file - and also the format that the array of 365 lines must be typed into the external text file. I am not a Javascript Programmer - and know nothing about Javascript, so please write your reply at my (lack of) knowledge Level. Thank you in advance! Here is the code I am using. <script language=javascript> <!-- Date.prototype.getDOY = function() {var onejan = new Date(this.getFullYear(),0,1); return Math.ceil((this - onejan) / 86400000);} var today = new Date(); var DOY = today.getDOY(); var HL=new Array() //Configure the following array to hold the 365 HLs for each day of the year HL[1]='HL 1 goes here' HL[2]='HL 2 goes here' HL[3]='HL 3 goes here' // Jump to Day 224 of the year for this example only HL[224]='I am surrounding myself with positive and supportive people. When I nurture relationships that give me energy and enjoyment, I mirror my beliefs that I deserve such gifts.' HL[225]='Today I affirm my own worth and value, and discover that the world agrees with me.' HL[226]='I am sowing seeds based on a healthy belief in my own self-worth. My life is flourishing with growing love, contentment, and exciting possibilities.' HL[227]='HL 227 goes here' HL[228]='HL 228 goes here' // Jump to last HL for Day 365 of year - for this example only HL[365]='HL 365 goes here' document.write(HL[DOY]) //--> </script> Hello, I actually use a counter on a webpage (It works) To do it, I use an inline javascript but I would like to unify the entire page and call that counter directly in the external Javascript that manages the whole site. Here's the actual code... Code: HTML <body onLoad=gen_hits()> ... <span id='hits'></span><SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/gcount.pl?NUMBER=../../otherdir/counter"></SCRIPT> ... </body> EXTERNAL JAVASCRIPT (ini.js) var hits="HITS "; function gen_hits() { document.getElementById("hits").innerHTML=hits; } and here a "view" of my request... Code: HTML <body onLoad=gen_hits()> ... <span id='hits'></span> ... </body> EXTERNAL JAVASCRIPT var hits="HITS " + <SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/gcount.pl?NUMBER=../../otherdir/counter"> </SCRIPT> ; function gen_hits() { document.getElementById("hits").innerHTML=hits; } Any idea how to modify it ? Thank you very much Gino favorite I'd like to modify a form on www.formsite.com (form builder app): username: testuser password: password I would like to use the nicedit.com's inline content editor's js to transform my textarea's into a richtext area. At present the nicedit editor works well in creating the richtextarea. However, the KEY point is that I would like formsite's form to pipe in the the created html and render it with the html component of formsite. Currently, the pipe function in formsite will only put out the html syntax in it's html module. action seen he http://fs8.formsite.com/testform/form1/index.html So this would be: 1. checking out my form on formsite.com 2. the script from nicedit.com is already installed in an html component. 3. changing or telling me the scripts/tags/or whatever for formsite form using formsites form builder (which allows some html/script editing). 4. changed so as to render the rich text entered on page 1 in page 2 instead of the html syntax. Any other solutions using formsite and any other richtextarea solutions would be great too! Hi i am using javascript for the first time and i have a problem .I have 2 files html and javascript file in seperate but i donot know how to make them work .the code is down below .Thanks in advance for help. HTML <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <meta name="description" content="Instagram API - usage" /> <meta charset=utf-8 /> <title></title> </head> <body> <input id="lat_input" type="number" value="60.221374"/> <input id="lng_input" type="number" value="24.805391"/> <button id="search_location">Search</button><br/> <button id="get_popular">Get popular</button> <div id="images"></div> </body> </html> Javascript file // API DOCUMENTATION: // Instagram Developer Documentation var clientId = 'e7538f47e197479d8d32a63ae3ae4cd2'; $('#search_location').click(function () { getMediaByLocation($('#lat_input').val(), $('#lng_input').val()); }); $('#get_popular').click(function () { getPopularImages(); }); function getMediaByLocation(lat, lng) { var o = { lat: lat, lng: lng, client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/search?callback=?', o, function (response) { processImages(response.data); }); } function getPopularImages() { var o = { client_id: clientId }; $.getJSON('https://api.instagram.com/v1/media/popular?callback=?', o, function (response) { processImages(response.data); }); } function processImages(array) { $('#images').empty(); $.each(array, function (index, element) { var fs = $('<fieldset>').appendTo('#images'); $('<img>').attr('src', element.images.low_resolution.url).appendTo(fs); if (element.caption) { $('<pre>').text(element.caption.text).appendTo(fs); } $.each(element.comments.data, function (index, comment) { $('<pre>').text('Comment from ' + comment.from.full_name + ': ' + comment.text).appendTo(fs); }); }); } Does anyone know how to accomplish this? I got the html file to show but none of the text in the file will show.
Hello, 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'm trying to include an HTML/CSS Navigation Bar in a JavaScript file for easy editing (instead of going from page to page changing the same thing). This is the HTML & CSS I want to include in the JavaScript file: <a style="border-left: 1px solid white; padding: 5px" class=menu href="Index.html" title="Home"> Home</a><a class=menu href="menu1.html" title="Portfolio"> Portfolio</a><a class=menu href="menu2.html" title="About Us"> About Us</a><a class=menu href="menu3.html" title="Media"> Media</a><a class=menu href="menu4.html" title="Store"> Store</a><a class=menu href="menu5.html" title="Contact Us"> Contact Us</a> -If this isn't possible to do in JavaScript, then what language can I do it in? Thank you for reading. Hi, I'm currently working on my portfolio website and would like to have information about my movie clips be retrieved from an XML document when a thumbnail is clicked. I am building my website in HTML and would like to retrieve the Xml using JavaScript. Any help would be appreciated. My XML is valid and structured as such: <?xml version="1.0" encoding="UTF-8"?> <work> <motion> <reel> <title id="Demo Reel 2009" project="Self Promotion" client="Self"> <![CDATA[This demo reel is primaraly a collection ......]]> </title> </reel> . . . . These are my initial variable definitions and readXML function in javascript: <script language="javascript"> var xmldom, workNode, motionNode, printNode, fineartNode, displayNode, titleNode; function readXMLDocument() { xmldom=createDocument(); xmldom.async=false; if (xmldom.parseError != 0) { alert("An error occurred: \nError Code " + xmldom.parseError.errorCode + "\n" + "Line: " + xmldom.parseError.line + "\n" + "Line Pos: " + xmldom.parseError.linepos + "\n" + "Reason: " + xmldom.parseError.reason); } else { alert("Document: " + xmldom.documentElement); alert("Root: " + xmldom.documentElement.tagName); alert("Child: " + xmldom.documentElement.firstChild.tagName); alert("Xml DOM: " + xmldom.xml); } xmldom.load("workinfo.xml"); workNode=xmldom.documentElement; motionNode=workNode.firstChild; printNode=motionNode.nextSibling; fineartNode=printNode.nextSibling; } . . . . A call to function revealText is called "onClick" of a thumbnail as such: <a href="videopages/reel.html" class="vid" target="video" onClick="revealText(0)"> This is function revealText: function revealText(x) { var title, project, client, info; readXMLDocument(); displayNode=motionNode.childNode[x]; titleNode=displayNode.firstChild; title=titleNode.getAttribute("id"); project=titleNode.getAttribute("project"); client=titleNode.getAttribute("client"); info=titleNode.getNodeValue(); titleSpan.innerHTML=title; projectSpan.innerHTML=project; clientSpan.innerHTML=client; infoSpan.innerHTML=info; } </script> and these are the spans they are written to: <span id="titleSpan" class="vidinfo"> <span id="projectSpan" class="vidinfo"> <span id="clientSpan" class="vidinfo"> <p id="infoSpan" class="content"> If you have read this far, I REALLLLY appreciate it. And any ideas as to what is wrong would help alot. I included a js file into my html file. Everything work well in firefox but intenet explorer does not display my js file content. please helppp Js file // JavaScript Document document.write(<div class="RightSideGallerybox"> <div class="RightBoxContext">News</div> <div class="RightBoxPictures"><img src="../image/BotanicalTreeDecoration.jpg" /></div> <div class="RightBoxPictures"><img src="../image/IMG_3304.JPG" /></div> <div class="RightBoxPictures"><img src="../image/IMG_0297.JPG" width="150" height="100" /></div> <div class="ImportantRemarks">High School Admissions</div> <div class="ListOfRemarks"> <ul> <li>A. Phillip Randolph HS</li> <li>Astor Collegiate</li> <li>Aviation High School</li> <li>Bard College HS</li> <li>Bayside High School</li> </ul> </div> </div>); html file <div class="RightSideWrap"> <div class="footertext"> <script type="text/javascript" src="gallery.js"></script> </div> <!-------------------------------middle parts - right side--------------------------> </div> </div> I have some javascript which applies alternative row colors to a table and also gives you a highlight effect when you mouseover the rows. However, the problem I have is that it applies to every table on my page, I only want it to apply to a specific table in the html file (I'm using frontpage), not all of them How would I go about doing this? The code is below, it has a bit of styling at the top before the javascript. <style type="text/css" media="all"> table.altsrowtable { width: 90%; margin: auto; border-collapse: collapse} td { border: 1px solid black; cursorointer;text-align:center} /* row 1 */ tr td { background: #edf3fe; } tr:hover td, tr.ie td { background: #e1e1ff; } /* row 2 */ tr.bis td { background: #D9ECFF; } tr.bis:hover td, tr.bisie td { background: #e1e1ff; } /* selected row 1 */ tr.sel:hover td, tr.selie td { background: #edf3fe; } /* selected row 2 */ tr.selbis:hover td, tr.selbisie td { background: #D9ECFF; } </style> <script type="text/javascript" span="altsrowtables" div="altsrowtable" id="altsrowtable" class="altsrowtable"> var IE = false; /*@cc_on IE=true; @*/ var r; function setRows(){ r = document.getElementsByTagName('TR'); for(var i=0;i<r.length;i++) r[i].className = (i/2 != Math.round(i/2))? '':'bis'; } function selectRow(aRow,add){ var c = aRow.className; if(add) setRows(); var b = aRow.className; if(IE) aRow.className = b==''? 'selie' : b=='bis'? 'selbisie' : c=='selie'? 'ie' : c=='ie'? 'selie' : c=='bisie'? 'selbisie' : c=='selbisie'? 'bisie' : ''; else aRow.className = b==''||c==''? 'sel' : b=='bis'||c=='bis'? 'selbis' : c=='selbis'? 'bis' : ''; } // roll-over (only for IE) function roll(what) { var c = what.className; what.className = c==''? 'ie' : c=='bis'? 'bisie' : c=='bisie'? 'bis' : c=='selbis'? 'selbisie' : c=='selbisie'? 'selbis' : c=='selie'? 'sel' : c=='sel'? 'selie' : ''; } // fire on loading onload= function() { setRows(); for(var i=0;i<r.length;i++) { if(IE) { r[i].onmouseover = function(){ roll(this); } r[i].onmouseout = function(){ roll(this); } } } } </script> <style type="text/css"> table.altrowstable { font-family: calibri; font-size:11px; color:#333333; border-width: 1px; border-color: #C0C0C0; border-collapse: collapse; } table.altrowstable th { border-width: 1px; "background-image:url('QP Header.png');" border-style: solid; border-color: #C0C0C0; font-size:12px; font-style:bold; } table.altrowstable td { border-width: 1px; border-style: solid; border-color: #a9c6c9; } </style> Thanks Sean I have a javascript file and a html file. On the html file I have an action (button) and would like to use some type of attribute of the onclick to call my function to open this html file. below is the beginning of my function: requestPanel_Forwardme: function() { view.opendialog("show_me") What other attributes of action can I use? can this function in my JS file be called and if so how would I call it? <action?? |