Thread: I am a crap coder JasonD
The title says it all really as I just dabble rather than program any more.
Anyway, I am dabbling with a bit of fun code atm and running a for loop within a for loop. I want to add another loop in there with a timer working as a delay that will change the content of several iframes that have had their names dynamicaly assigned by the for loop. How do I do it ? Example code below and thanks for your help guys n gals. <script> for (r = 1; r < Multiplier; r++){ for(i = 1; i < AmountofViews; i++){ var url="http://www.XXXXXXXXXXX>XXX"+"&"+Math.random(); document.write('Viewing Number:'+i+'<iframe name = "framename'+i+'""src ="'+url+'"width="10" height="10"></iframe><br>'); } // code here to pause browser to allow pages to load // code here to reload iframes Multipler times } </script> perkiset
The only thing worse than your coding is your explanations
quote author=JasonD link=topic=403.msg2606#msg2606 date=1184369375 I want to add another loop in there with a timer working as a delay that will change the content of several iframes that have had their names dynamicaly assigned by the for loop. <script> for (r = 1; r < Multiplier; r++) { for (i=1; i < AmountofViews; i++) { var url="http://www.XXXXXXXXXXX>XXX"+"&"+Math.random(); document.write('Viewing Number:'+i+'<iframe name = "framename'+i+'""src ="'+url+'"width="10" height="10"></iframe><br>'); } // code here to pause browser to allow pages to load // code here to reload iframes Multipler times } </script> OK - sounds to me like you're trying to dynamically add iFrames to the page at a random interval... yes? First off - there is no "sleep" in JS - you cannot create a blocking call. Therefore, the way to do this is actually to set a random amount of time to a setTimeout() function which will call <the next iFrame function> in a random number of ms. Before I go deep, please tell me if I am on the right track and I can tell you how to do it. Randomly changing ads, or perhaps ... hehehe... /p JasonD
I appreciate there is no pause function in JS, but I also think I can get to where I need to via something like
setTimeout("document.write('hello world')",1000); You're not far off mate, but it aint ads it is......... *** OOOPS ME SHUTS UP BUT MIGHT EXPLAIN IF YOU TURN SKYPE ON *** But I don't know how to change the Iframes named as in the example (and crap) code. perkiset
quote author=JasonD link=topic=403.msg2608#msg2608 date=1184370773 I appreciate there is no pause function in JS, but I also think I can get to where I need to via something like setTimeout("document.write('hello world')",1000); Zactly right, although I personally do not care for document.write. quote You're not far off mate, but it aint ads it is......... *** OOOPS ME SHUTS UP BUT MIGHT EXPLAIN IF YOU TURN SKYPE ON *** Heh... thought so from whence you 'n me came, my imagination has no problems with where you might be. I'd turn on me SKYPE but unfortunately I am on my notebook right now and haven't set it up here - we had an air conditioning unit explode on us day-before-last and the spike (as it grounded itself) actually made it through my batteries and surge protector and took out my main Mac. It's in the shop now seeing if it is only a power supply. S'posen I should get skype going here...quote But I don't know how to change the Iframes named as in the example (and crap) code. Here is an interesting article - it actually talks about remote scripting using iFrames rather than ... um, well where you might be, but at the bottom is a rather fleshed out chunk of code that shows how to create and destroy iFrames dynamically and with strong support in virtually all browsers. Good reading. Here: http://developer. apple.com/internet/webcontent/iframe.htmlPing back if that's not answering you. /p JasonD
ping
lol perkiset
:
Awright ya bloody wanker. PM me here with more crisp details please and lemmee see... /p JasonD
Shit I am still a crap coder.
Why on earth don't I do this in Perlas it would take 10 minutes ?I think the answer is cos I know it can be done in JS, the problem is I simply am crap lol perkiset
What's the issue now?
Are you willing to post your code here? |
Thread Categories
Best of The Cache Home | ||
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads