Skip to main content

Posts

Showing posts with the label Javascript

Looping through IFrames using Javascript (ie. js)

I'll just paste some code here. It should be self explainatory... /****************************************************************************************** Requirements: 1. <body onLoad="wt_ad_impression()"> 2. <div id="wt_call"></div> somewhere in body 3. <input type="hidden" id="wt_name" name="wt_name" value="wt.AD" /> at Xigla Edit Banner 4. <iframe></iframe> not <iframe /> for FireFox in Ad Zone Grouping *******************************************************************************************/ var intervalId = 0; var wt_iframes = null; var iframeCount = 0; var iframeIterator = 0; function wt_ad_impression() { alert("called"); wt_iframes = document.getElementsByTagName("iframe"); iframeCount = wt_iframes.length; intervalId = setInterval(wt_collect, 200); } function wt_collect() { alert("in wt_collect"); alert(...

document.getElementByName()

<input type="text" name="somename" value="somevalue1" /> <input type="text" name="somename" value="somevalue2" /> <input type="text" name="somename" value="somevalue3" /> <script type="text/javascript"> var x = document.getElementByName('somename'); // document.getElementByName() returns an array where //x[0].value == "somevalue1"; //x[1].value == "somevalue2" </script> Note: getElementByName() only works for form elemnts if you need other elements a workaround would be to use var element = getElementByTagName() and assign a class to each element then you could look for that class using if element[index].className == "somename".