JavaScript - Change Div Content Via Java Scirpt
HI every one
I want to change a div content in my page via javascript , the problem is the index.php file is coded and I can't read it , but I could execute some JavaScript codes from somewhere else . The problem is that the <div> is in the lowest side of the page and my javascript code is above it , so The javascript code runs first and It couldn't find the div because it's not loaded yet . my javascript code is something like this : <script> document.getElementById("test").innerHTML= "ddd"; </script> <div id="test">dude</div> in the example above , it's not working But if I insert the JavaScript below the <div> it's working . How can I run it in this example ? If the javascript code is above the <div> , how can I change the div's content ? Thanks Similar TutorialsI can`t play video from the internet full screen. I keep getting this message that I need to change the Java script setting to re size window. I tried a lot of things and still not working. How can I change the settings?
Hi First sorry for my bad English! may any one interpret the JavaScript code below for me? A Device code ( a "random number") and the DVD code gives an activation code! Each install time a random number and thus a new activation code! i works in cookie base manner! clear cookie couse program become unusable and another activation will be needed! I want to change random Number to a fix one so it Becomes constant and does not change regularly! and then no need for change activation code... Where do I change? I'm sure help ... best regards thanks ----------------------------------------------------------------------------------- <html> <head> <title>Activation</title> <script type="text/javascript" src="../js/ajax.js"></script> <script type="text/javascript"> var _0x8834=["\x72\x65\x70\x6C\x61\x63\x65","\x68\x72\x65\x66", "\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x73\x65\x72\x 69\x61\x6C","\x61\x63\x74\x69\x76\x61\x74\x69\x6F\ x6E\x43\x6F\x64\x65","\x72\x61\x6E\x64","\x73\x75\ x62\x73\x74\x72\x69\x6E\x67","\x4D\x6F\x62\x69\x55 \x70\x54\x6F\x44\x61\x74\x65\x5F\x33","\x4D\x6F\x6 2\x69\x55\x70\x54\x6F\x44\x61\x74\x65\x5F\x34","\x 4D\x6F\x62\x69\x55\x70\x54\x6F\x44\x61\x74\x65\x5F \x35","\x2E\x2E\x2F\x4D\x6F\x62\x69\x55\x70\x54\x6 F\x44\x61\x74\x65\x2E\x68\x74\x6D\x3F"];function GET(){var _0x84efx2={};var _0x84efx3=window[_0x8834[2]][_0x8834[1]][_0x8834[0]](/[?&]+([^=&]+)=([^&]*)/gi,function (_0x84efx4,_0x84efx5,_0x84efx6){_0x84efx2[_0x84efx5]=_0x84efx6;} );return _0x84efx2;} ;if(GET()[_0x8834[3]]!=undefined&&GET()[_0x8834[4]]!=undefined&&GET()[_0x8834[5]]!=undefined){var num=(parseInt(GET()[_0x8834[3]][_0x8834[6]](0,7))%5555)*(parseInt(GET()[_0x8834[5]]%30)+1);if(num==parseInt(GET()[_0x8834[4]])){setf(_0x8834[7],GET()[_0x8834[5]]);setf(_0x8834[8],GET()[_0x8834[3]]);setf(_0x8834[9],GET()[_0x8834[4]]);window[_0x8834[2]]=_0x8834[10];} ;} ; </script> </head> <body align="center"> <h1>Activation</h1> To get activation code visit*************<br> <script language="javascript"> if (GET()['serial']!=undefined) document.write('<br>Incorrect serial or activation code. Try again please!<br>'); </script> <form action="./activation.htm?" method="GET"> <table align="center"> <tr> <td>Device code:</td> <td><script language="javascript"> if (getf('rand_num')==undefined) setf('rand_num', Math.floor(Math.random()*9999)); var rand_num=getf('rand_num'); document.write(rand_num+'<INPUT TYPE="hidden" NAME="rand" VALUE="'+rand_num+'">'); </script></td> </tr> <tr> <td>Serial</td> <td> <input name="serial"></input></td> </tr> <tr> <td>Activation code</td> <td> <input name="activationCode"></input></td> </tr> </table> <input type='submit' value="Activate"></input> </form> </body> </html> I am new to Java/AJAX and I am trying to create a script that will change content of a div. My scenario I am using is an index page with the list.php script included in the div I want content changed in. The list.php script will pull 8 newest titles from mysql and list them in the div. When you click one of the titles it will redirect you to a new page created by story.php. I would like this to be contained inside the div I have currently have the list.php script in. I have looked at several tutorials on AJAX to do this, but they always call a static html page. Since I am not using a static html page I do not think this solution would work for me. How my list.php script works is as follows: PHP Code: // generate and execute query $query = "SELECT id, title, timestamp FROM news ORDER BY timestamp DESC LIMIT 0, 8"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print news titles while($row = mysql_fetch_object($result)) { ?> <b><font size="+2"><a href="story.php?id=<? echo $row->id; ?>"><? echo $row->title; ?></a></b></font> <br> <font size="-2"><center><? echo formatDate($row->timestamp); ?></center></font> <p> <? } } // if no records present // display message else { ?> <font size="-1">No news is bad news</font> <? } How my story.php script works is as follows: PHP Code: // generate and execute query $query = "SELECT title, content, contact, timestamp FROM news WHERE id = '$id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // get resultset as object $row = mysql_fetch_object($result); // Show me the news if ($row) { ?> <p> <b><? echo $row->title; ?></b> <p> <font size="-1"><? echo nl2br($row->content); ?></font> <p> <font size="-2">Posted on <? echo formatDate($row->timestamp); ?>. By <? echo $row->contact; ?></font> <? } else { ?> <p> <font size="-1">That news post could is not found.</font> <? } If you need more information for this I will provide whatever you need. I have a form with a postcode field in it I want to add a button or text link next to this field which if clicked on goes to the google maps url querying that postcode i.e. if the postcode text in the field (form not submitted) was SW1A 1AA then without submitting that form there would be a button / link next to it which when clicked on went to "http://maps.google.co.uk/?q=SW1A1AA" Pretty sure Java should be able to do this ? Hi everyone In the below code i tried to write java scirpt in action attribute of form tag in html . Why i wrote that was i want to get the scirpt variable as a part of the url of the target page . I also tried using the location.href="targetpage?value="+value . But It is not redirecting to targetpage because of the action attribute in the form tag. And if we use location.href without action attribute only that script variable was posted and all other remaining textboxes and other form items are being not posted .. Thats why I wrote the scirpt in action attribute. I want the action attribute to work and also the java script variable to be posted .so i wrote the script tag in action attribute of form tag . I hope u got the Scenario . Please help me to resolve the issue.. Thank in advance .. <!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>Untitled Document</title> </head> <body> <? if($_POST['submit'] ) { $var = $_GET['width'] ; } ?> <form name="form_submit" method="post" action="test2.php?width= '<script type= text/javascript> document.write(num)</script>' " onsubmit="return fun(); "> <script type="text/javascript"> function fun() { width = screen.width; height = screen.height; if (width > 0 && height >0) { window.location.href = "http://localhost/test2.php?width=" + width + "&height=" + height; } else exit(); } </script> <input type="text" name="txt" value="sample text" /> <input type="submit" name="submit" value="submit" /> </form> </body> </html> I want a code that changes text (of maybe a div) after 10 seconds. So like i could have some text and a link on my page then after 10 seconds it will change to something else and i can make it change to as many things as i want. Then when it goes threw them all it starts over. THANKS I have a div that changes background on click. Example: <script type="text/javascript"> function changeBackground(strURL) { document.getElementById('about').style.backgroundImage="url("+strURL+")"; } </script> <body> <div id="about"> <a href="#about" onClick="changeBackground('mainbackground.jpg');">text</a> <a href="#about" onClick="changeBackground('background2.jpg');">text</a> </div> This part works just fine so no issues. However, I have content on the mainbackground.jpg that is getting transferred over to the other backgrounds as well. I would like each background to have its own paragraph content. I do not want to embed the info into the images for SEO reasons. Any ideas on how to do this? Thanks! I am trying to get a div's content to change using javascript but for some reason it is not working and i get no errors looking at the error console. the code that is waiting for the content... Code: <div style="font-weight: bold;">count = <div id="desc" style="float: left;"></div> descriptions to do.</div><br clear="all" /> the code that should change the content.... Code: <? echo("<script type=\"text/javascript\"> document.getElementById('desc').value='" . $count . "'; </script>"); ?> when i view the source code the javascript lines show like so... Code: <script type="text/javascript"> document.getElementById('desc').value='373'; </script> do i have the javascript correct ? I have a div that changes background on click. Example: <script type="text/javascript"> function changeBackground(strURL) { document.getElementById('about').style.backgroundImage="url("+strURL+")"; } </script> <body> <div id="about"> <a href="#about" onClick="changeBackground('mainbackground.jpg');">text</a> <a href="#about" onClick="changeBackground('background2.jpg');">text</a> </div> This part works just fine so no issues. However, I have content on the mainbackground.jpg that is getting transferred over to the other backgrounds as well. I would like each background to have its own paragraph content. I do not want to embed the info into the images for SEO reasons. Any ideas on how to do this? Thanks! Hi all I'm rather new to java scripting and trying to get this done for over a week now. I'm building a complete new site (not online yet) which is done for 99,9% The site consists of: Index - No frames - Just an entrance of the site with links main menu Section1 - 1 iframe ("iframe1") - default src=iframe1defaultsection1content main menu submenu section1 Section2 - 2 iframes ("iframe1","iframe2") - default src = iframe1defaultsection2content - frame2 contains images that change main menu submenu section2 Section3 - 1 iframe ("iframe1") - default src=iframe1defaultsection3content main menu submenu section3 Section4 - 1 iframe ("iframe1") - default src=iframe1defaultsection4content main menu submenu section4 Contact - 1 iframe ("iframe1") - default src=iframe1defaultcontactcontent main menu submenu contact The main menu is plain html that is on every page I use javascripts to make a loadIframeFunction load content into the iframes Code: <head> <script type="text/javascript> var iframeids=["iFrame1"] var iframehide="yes" function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } </script> </head> <body> <iframe id="iframe1" src="iframesection1start.html" width="644px" height="385px" style="position:absolute; left:505px; top:275px; z-index:73 scrolling="yes" marginwidth="0" marginheight="0" frameborder="0"></iframe> <a href="javascript:loadintoIframe('iframe1', 'iframecontent.html')" title="content">Content</a> </body> Everything works, but 1 thing. i can't get the links in the index page link to the specific section page AND change the default src content can anybody assist me pls? I'm beginner, and there is a task in exam to change inner content of the second child node. Can't get, please help or maybe link to an article how to do it, because I can't find anything in my study book; edit: is this correct? function SetUpTranslation() { var phrases = document.getElementsByTagName('p'); for (var i=0; i < p.attributes.length; i++){ phrases.secondNode.innerHTML=french[i]; element.onclick=swapFE(phrases.secondNode); element.onmouseup=swapFE(phrases.secondNode); } } hi all, I really need help with this topic. I have to use onMouseOver to change the content of an iframe. I'm trying to use an array but I'm confused and I'm not really sure if what I'm doing is correct and it doesnt work. I will appreciate your help and understanding. Thanks a lot! here is part of my code.. var frame=new Array(6); frame[0]="page1.html"; frame[1]="page2.html"; frame[2]="page3.html"; frame[3]="page4.html"; frame[4]="page5.html"; frame[5]="page6.html"; var j=0; function nextFrame() { if (j < 5) { j++; document.getElementById(frame).contentDocument=frame[j]; } return; } <span onMouseOver="nextFrame()" > <img name="upperImage" src="something.jpg" width=350 height=250 /></span> <iframe id="frame1" name="frame1" src="" width=350 height=250 frameborder="0"> </iframe> Please let me know if at least I'm in the right track. Thanks Hi , I am new to javascript and have coded an invoice page through help from some available content on web. here is my requirement My form contains inputs "item ,rate quantity,price" in a tabular form where one can dynamically add or delete rows.And the requirement is that when Quantity is entered the Price should change to Price=Quantity*Rate on tab out So I have used a Javascript onchange() and this works fine for the first displayed row. but for dynamically added rows this does not happen, I am not able change the price value for dynamically added rows. Code is as below direct_invoice.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script type="text/javascript" src="js/direct_invoice_table.js"> </script> <html> <head> <title>Direct Invoice</title> </head> <body leftmargin="0" topmargin="0"> <p align = "center" font='30'><input type="text" name="company_name" size="20" maxsize="20" /> <b> Invoice</b></p> <table id="Client_Details"> <tr> <th>Client Name:</th> <td><input type="text" name="client_name" size="20" maxsize="20" /></td> </tr> <tr> <th>Client Address:</th> <td><input type="text" name="address_line1" size="20" maxsize="40" /></td> </tr> <tr> <td></td> <td><input type="text" name="address_line2" size="20" maxsize="40" /></td> </tr> <tr> <th>Pin Code:</th> <td><input type="text" name="client_pin" size="7" maxsize="7" /></td> </tr> <tr> <th>City/State/Country:</th> <td><input type="text" id="client_city" size="10" maxsize="30" /></td><td>/</td> <td><input type="text" id="client_state" size="10" maxsize="20" /></td><td>/</td> <td><input type="text" id="client_country" size="10" maxsize="20" /></td> </tr> <tr> <th>Email Address:</th> <td><input type="text" name="client_city" size="10" maxsize="30" /></td> </tr> <tr> <th>TIN/PAN:</th> <td><input type="text" name="tin_or_pan" size="10" maxsize="20 " /></td> </tr> </table> <table align="center" width = "75%"> <tr> <td align = "center"> <!--- very imporant to give the table an id ---> <!--- otherwise it won't know where to edit ---> <table border="1" id="mySampleTable"> <tr> <th>Item No</th> <th>Item Name</th> <th>Description</th> <th>Unit Cost</th> <th>Quantity</th> <th>Price</th> <th> <font color="RED">Delete</font></th> </tr> <tr> <td>1</td> <td><input type="text" name="itemname[]" size="40" "maxsize="100"/></td> <td><input type="text" name="description[]" size="20" " maxsize="100" /></td> <td><input type="text" id = "unitcost[]" name="unitcost[]" size="10" maxsize="100" /></td> <td><input type="text" id = "quantity[]" name="quantity[]" onchange="dynamic_onc();" size="4" maxsize="100" /></td> <td><input type="text" id = "price[]" name="price[]" size="10" maxsize="100" /></td> </tr> </table> <table id="totaltbl" align="right"> <tr> <td></td> </tr> <tr> <th>Vat %</th> <td><input type="text" name="total" size="3" maxsize="3" /></td> </tr> <tr> <th>Total</th> <td><input type="text" id = "total" name="total" size="20" maxsize="100" /></td> </tr> </table> </td> </tr> </table> <form action="save_entry.php" name="eval_edit" method="post" format="html"> <p> <input type="button" value="Add Row" onclick="addRow();" /> <input type="button" value="Calculate Total Amount" onclick="Totalcal();" /> <input type="button" value="Print" /> </p> </form> <p align = "left" font='100'> <b>Company Name: </b> <input type="text" name="company_address_line1" size="20" maxsize="20" /> </p> <p align = "left" font='100'> <b>Company address line: </b> <input type="text" name="company_address_line2" size="20" maxsize="20" /></p> <p align = "left" font='100'> <b>Company Location: </b><input type="text" name="company_address_location" size="20" maxsize="20" /></p> </body> </html> *************** The below is the javascript function that i wrote Code: function addRow() { // grab the element, i.e. the table your editing, in this we're calling it // 'mySampleTable' and it is reffered to in the table further down on the page // with a unique of id of you guessed it, 'mySampleTable' var tbl = document.getElementById('mySampleTable'); // grab how many rows are in the table var lastRow = tbl.rows.length; // if there's no header row in the table (there should be, code at least one //manually!), then iteration = lastRow + 1 var iteration = lastRow; // creates a new row var row = tbl.insertRow(lastRow); // left cell // insert a cell var cellLeft = row.insertCell(0); // here we're just using numbering the cell, like anything else you don't // have to use this, but i've kinda noticed users tend to like them var textNode = document.createTextNode(iteration); // takes what we did (create the plain text number) and appends it the cell // we created in the row we created. NEAT! cellLeft.appendChild(textNode); // right cell // another cell! var cellRight1 = row.insertCell(1); // creating an element this time, specifically an input var el = document.createElement('input'); // a data type of text el.type = 'text'; // the name of the element itemname, and because this is dynamic we also // append the row number to it, so for example if this is the eigth row // being created the text box will have the name of itemname8. super fantastic. // the exact same thing with a unique id el.id = 'itemname[]'+ iteration; // set it to size of 40. setting sizes is good. el.size = 40; // same thing as earlier, append our element to our freshly and clean cell cellRight1.appendChild(el); var cellRight2 = row.insertCell(2); var e2 = document.createElement('input'); e2.type = 'text'; e2.id = 'description[]' + iteration; e2.size = 20; e2.maxsize = 100; cellRight2.appendChild(e2); var cellRight3 = row.insertCell(3); var e3 = document.createElement('input'); e3.type = 'text'; e3.id = 'unitcost[]' + iteration; e3.size = 10; e3.maxsize = 100; cellRight3.appendChild(e3); var cellRight4 = row.insertCell(4); var e4 = document.createElement('input'); e4.type = 'text'; e4.id = 'quantity[]'+ iteration; e4.size = 4; e4.maxsize = 100; cellRight4.appendChild(e4); var cellRight5 = row.insertCell(5); var e5 = document.createElement('input'); e5.type = 'text'; e5.id = 'price[]'+ iteration; e5.size = 10; e5.maxsize = 100; cellRight5.appendChild(e5); // var cellRight7 = row.insertCell(7); // var e7 = document.createElement('input'); // e7.type = 'CHECKBOX'; // e7.id = 'cancel[]'; // cellRight7.appendChild(e7); var cellRight6 = row.insertCell(6); cellRight6.innerHTML = " <input type='button' value='Delete' size='6' onclick='removeRow(this);'/>"; e4.onclick = dynamic_onc(); } function removeRow(src) { /* src refers to the input button that was clicked. to get a reference to the containing <tr> element, get the parent of the parent (in this case case <tr>) */ var oRow = src.parentElement.parentElement; //once the row reference is obtained, delete it passing in its rowIndex document.all("mySampleTable").deleteRow(oRow.rowIndex); } function countRow() { var Rowcount = document.getElementById('mySampleTable').rows.length; document.eval_edit.count.value = Rowcount-1; } function CalculatePrice() { var Rowcount = document.getElementById('mySampleTable').rows.length; document.eval_edit.count.value = Rowcount-1; } function onc() { var a= document.getElementById('unitcost[]'); var b= document.getElementById('quantity[]'); var c = Math.ceil(a.value*b.value); alert(b); document.getElementById('price[]').value =c; } function dynamic_onc() { alert('Jay' ); e5.value =7; } function Totalcal() { var a= document.getElementById('unitcost[]'); var b= document.getElementById('quantity[]'); var c = Math.ceil(a.value*b.value); alert(b.value); document.getElementById('price[]').value =c; } hey guys i downloaded the 'Content Slider v2.4', and this has a feature which will save a cookie used to remember and recall the last content viewed by the user when they return to the page. (click here for more information on the script.) the only thing is that this is made for pages with URLs such as: Quote: www.mysite.com/gallery_album_1/content.php but my URLS are set out like: Quote: www.mysite.com/content.php?gallery_album_1 is there a way to make to so the cookie remembers the page via the "php?gallery_album_1" part instead of the "content.php" part. i need it to be like this simply because i have multiple galleries coming from the oe page, eg: Quote: www.mysite.com/content.php?gallery_album_1 www.mysite.com/content.php?gallery_album_2 www.mysite.com/content.php?gallery_album_3 the main code of the js is as follows: Code: //** Featured Content Slider script- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com. //** May 2nd, 08'- Script rewritten and updated to 2.0. //** June 12th, 08'- Script updated to v 2.3, which adds the following features: //1) Changed behavior of script to actually collapse the previous content when the active one is shown, instead of just tucking it underneath the later. //2) Added setting to reveal a content either via "click" or "mouseover" of pagination links (default is former). //3) Added public function for jumping to a particular slide within a Featured Content instance using an arbitrary link, for example. //** July 11th, 08'- Script updated to v 2.4: //1) Added ability to select a particular slide when the page first loads using a URL parameter (ie: mypage.htm?myslider=4 to select 4th slide in "myslider") //2) Fixed bug where the first slide disappears when the mouse clicks or mouses over it when page first loads. var featuredcontentslider={ //3 variables below you can customize if desired: ajaxloadingmsg: '<div style="margin: 20px 0 0 20px"><img src="../images/loading.gif" /> Fetching slider Contents. Please wait...</div>', bustajaxcache: true, //bust caching of external ajax page after 1st request? enablepersist: true, //persist to last content viewed when returning to page? settingcaches: {}, //object to cache "setting" object of each script instance jumpTo:function(fcsid, pagenumber){ //public function to go to a slide manually. this.turnpage(this.settingcaches[fcsid], pagenumber) }, ajaxconnect:function(setting){ var page_request = false if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else return false var pageurl=setting.contentsource[1] page_request.onreadystatechange=function(){ featuredcontentslider.ajaxpopulate(page_request, setting) } document.getElementById(setting.id).innerHTML=this.ajaxloadingmsg var bustcache=(!this.bustajaxcache)? "" : (pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', pageurl+bustcache, true) page_request.send(null) }, ajaxpopulate:function(page_request, setting){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(setting.id).innerHTML=page_request.responseText this.buildpaginate(setting) } }, buildcontentdivs:function(setting){ var alldivs=document.getElementById(setting.id).getElementsByTagName("div") for (var i=0; i<alldivs.length; i++){ if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv" setting.contentdivs.push(alldivs[i]) alldivs[i].style.display="none" //collapse all content DIVs to begin with } } }, buildpaginate:function(setting){ this.buildcontentdivs(setting) var sliderdiv=document.getElementById(setting.id) var pdiv=document.getElementById("paginate-"+setting.id) var phtml="" var toc=setting.toc var nextprev=setting.nextprev if (typeof toc=="string" && toc!="markup" || typeof toc=="object"){ for (var i=1; i<=setting.contentdivs.length; i++){ phtml+='<a href="#'+i+'" class="toc">'+(typeof toc=="string"? toc.replace(/#increment/, i) : toc[i-1])+'</a> ' } phtml=(nextprev[0]!=''? '<a href="#prev" class="prev">'+nextprev[0]+'</a> ' : '') + phtml + (nextprev[1]!=''? '<a href="#next" class="next">'+nextprev[1]+'</a>' : '') pdiv.innerHTML=phtml } var pdivlinks=pdiv.getElementsByTagName("a") var toclinkscount=0 //var to keep track of actual # of toc links for (var i=0; i<pdivlinks.length; i++){ if (this.css(pdivlinks[i], "toc", "check")){ if (toclinkscount>setting.contentdivs.length-1){ //if this toc link is out of range (user defined more toc links then there are contents) pdivlinks[i].style.display="none" //hide this toc link continue } pdivlinks[i].setAttribute("rel", ++toclinkscount) //store page number inside toc link pdivlinks[i][setting.revealtype]=function(){ featuredcontentslider.turnpage(setting, this.getAttribute("rel")) return false } setting.toclinks.push(pdivlinks[i]) } else if (this.css(pdivlinks[i], "prev", "check") || this.css(pdivlinks[i], "next", "check")){ //check for links with class "prev" or "next" pdivlinks[i].onclick=function(){ featuredcontentslider.turnpage(setting, this.className) return false } } } this.turnpage(setting, setting.currentpage, true) if (setting.autorotate[0]){ //if auto rotate enabled pdiv[setting.revealtype]=function(){ featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } sliderdiv["onclick"]=function(){ //stop content slider when slides themselves are clicked on featuredcontentslider.cleartimer(setting, window["fcsautorun"+setting.id]) } setting.autorotate[1]=setting.autorotate[1]+(1/setting.enablefade[1]*50) //add time to run fade animation (roughly) to delay between rotation this.autorotate(setting) } }, urlparamselect:function(fcsid){ var result=window.location.search.match(new RegExp(fcsid+"=(\\d+)", "i")) //check for "?featuredcontentsliderid=2" in URL return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index }, turnpage:function(setting, thepage, autocall){ var currentpage=setting.currentpage //current page # before change var totalpages=setting.contentdivs.length var turntopage=(/prev/i.test(thepage))? currentpage-1 : (/next/i.test(thepage))? currentpage+1 : parseInt(thepage) turntopage=(turntopage<1)? totalpages : (turntopage>totalpages)? 1 : turntopage //test for out of bound and adjust if (turntopage==setting.currentpage && typeof autocall=="undefined") //if a pagination link is clicked on repeatedly return setting.currentpage=turntopage setting.contentdivs[turntopage-1].style.zIndex=++setting.topzindex this.cleartimer(setting, window["fcsfade"+setting.id]) setting.cacheprevpage=setting.prevpage if (setting.enablefade[0]==true){ setting.curopacity=0 this.fadeup(setting) } if (setting.enablefade[0]==false){ //if fade is disabled, fire onChange event immediately (verus after fade is complete) setting.contentdivs[setting.prevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.prevpage, setting.currentpage) } setting.contentdivs[turntopage-1].style.visibility="visible" setting.contentdivs[turntopage-1].style.display="block" if (setting.prevpage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[setting.prevpage-1], "selected", "remove") if (turntopage<=setting.toclinks.length) //make sure pagination link exists (may not if manually defined via "markup", and user omitted) this.css(setting.toclinks[turntopage-1], "selected", "add") setting.prevpage=turntopage if (this.enablepersist) this.setCookie("fcspersist"+setting.id, turntopage) }, setopacity:function(setting, value){ //Sets the opacity of targetobject based on the passed in value setting (0 to 1 and in between) var targetobject=setting.contentdivs[setting.currentpage-1] if (targetobject.filters && targetobject.filters[0]){ //IE syntax if (typeof targetobject.filters[0].opacity=="number") //IE6 targetobject.filters[0].opacity=value*100 else //IE 5.5 targetobject.style.filter="alpha(opacity="+value*100+")" } else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax targetobject.style.MozOpacity=value else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax targetobject.style.opacity=value setting.curopacity=value }, fadeup:function(setting){ if (setting.curopacity<1){ this.setopacity(setting, setting.curopacity+setting.enablefade[1]) window["fcsfade"+setting.id]=setTimeout(function(){featuredcontentslider.fadeup(setting)}, 50) } else{ //when fade is complete if (setting.cacheprevpage!=setting.currentpage) //if previous content isn't the same as the current shown div (happens the first time the page loads/ script is run) setting.contentdivs[setting.cacheprevpage-1].style.display="none" //collapse last content div shown (it was set to "block") setting.onChange(setting.cacheprevpage, setting.currentpage) } }, cleartimer:function(setting, timervar){ if (typeof timervar!="undefined"){ clearTimeout(timervar) clearInterval(timervar) if (setting.cacheprevpage!=setting.currentpage){ //if previous content isn't the same as the current shown div setting.contentdivs[setting.cacheprevpage-1].style.display="none" } } }, css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") else if (action=="add") el.className+=" "+targetclass }, autorotate:function(setting){ window["fcsautorun"+setting.id]=setInterval(function(){featuredcontentslider.turnpage(setting, "next")}, setting.autorotate[1]) }, getCookie:function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null }, setCookie:function(name, value){ document.cookie = name+"="+value }, init:function(setting){ var persistedpage=this.getCookie("fcspersist"+setting.id) || 1 var urlselectedpage=this.urlparamselect(setting.id) //returns null or index from: mypage.htm?featuredcontentsliderid=index this.settingcaches[setting.id]=setting //cache "setting" object setting.contentdivs=[] setting.toclinks=[] setting.topzindex=0 setting.currentpage=urlselectedpage || ((this.enablepersist)? persistedpage : 1) setting.prevpage=setting.currentpage setting.revealtype="on"+(setting.revealtype || "click") setting.curopacity=0 setting.onChange=setting.onChange || function(){} if (setting.contentsource[0]=="inline") this.buildpaginate(setting) if (setting.contentsource[0]=="ajax") this.ajaxconnect(setting) } } as far as i can see, the parts of the code which are about the cookies are labeled "enablepersist" thanks guys Hi guys, The code in question is www.spectral.og.uk/test5/work2.htm I am trying to change the main 'SPECTRAL' video content mid-right when I click on the 'Change Movie' at the bottom. Eventually I want to be able to do this from the thumbnails but Im just running a simple test first. So I defined the function 'ChangeMOVIE' on line 14 using document.getElementById & innerHTML, etc, to replicate the flash player script contents that are incidentally ID'd as "BIGCHANGE" (ie, part of the main flash player on line 249) but simply replacing a different name for the video when it reaches the Flashvars "&file=Splash.flv" to something else to effect the change of video content I'm after, 'Olay.flv' I think. I have tried so hard to research into this but it just doesn't work. Is the problem to do with that :- 1) You can't ID something within <script>, ie BIGCHANGE in this instance. 2) innerHTML is only really for text replacement, not the amount of script I've stuck into it to replace within the whole <TD> cell with ID 'VID' (ie the main flash player) even though I've used delimiters and everything within the innerHTML data to try and not confuse it with apostrophes within speach marks, etc Any thoughts where I'm going wrong? Maybe Im barking up the wrong tree on this! Thanks so much guys for any headsup on a solution to this as I've been up all night for about a week on this! Dom Is there a Javascript code to change multiple affilate link/content daily?
The project I am working on involves a flash piece that communicates with a iframe. Currently the flash piece just calls on javascript functions. I want the buttons in the flash piece to be able to change the src of the iframe. PHP Code: <script type="text/javascript"> document.getElementById('video').setAttribute('src',address2); function closeVideo() { document.getElementById('video').style.height='0px'; return false; document.getElementById('video').setAttribute('src', address2); } function openVideo() { document.getElementById('video').style.height='391px'; return false; document.getElementById('video').setAttribute('src', address); } </script> So the way the code works now is when the page loads it sets the iframe with the id of 'video' to the variable address2 which it pulls from an XML file. In the flash piece when a button is hit, it calls openVideo() which "opens" the iframe and I want it to change the contents to address. This does not work though. It opens the frame but will not change the src. I've tried a bunch of different things now such as make the flash target the iframe using navigateToURL(request1, 'video'); but in Firefox and IE is opens it stills as if I had _blank in there. It does strangely work in Safari. Any ideas how to get this to work? I'm new to javascript so it could be something basic I'm overlooking Hi Coders, I was wondering if anyone knows how you would create a link when clicked will change the width of the content. I have a feeling this will use jQuery? E.g. A link saying 'expand' will change the width of the body to 1000px and change the link to 'contract'. When the link 'contract' is clicked it will change the width back to 800px and change the link to 'expand' Thanks in advance! Haydn. |