473,382 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

What do I change so this js doesn't interfere with another?

tpgames
785 512MB
Expand|Select|Wrap|Line Numbers
  1. window.onload = initiFrame;
  2.  
  3. function initiFrame() {
  4.     for (var i=0; i<document.links.length; i++) {
  5.         document.links[i].target = "content";
  6.         document.links[i].onclick = setiFrame;
  7.     }
  8. }
  9.  
  10. function setiFrame() {
  11.     document.getElementById("content").contentWindow.document.location.href = this.href;
  12.     return false;
  13. }
  14.  
The above code interferes with the below code. The above won't work at all if I use the below code. The link automatically opens up in a new window instead of in the iframe like its supposed to. The following link is the correct behavior.
Correct
Here is the wrong behavior link.
Wrong

Expand|Select|Wrap|Line Numbers
  1. imgName = new Array()
  2. for (x=1; x<=40; x++) {
  3. imgName[x] = x
  4. }
  5.  
  6. contextPath = "http://i107.photobucket.com/albums/m287/tpkyteroo/ah/";
  7. extension = ".jpg";
  8. current = 1;
  9.  
  10. window.onload = randomizeImage
  11.  
  12. function randomizeImage() {
  13.  
  14. changeImg()
  15. }
  16.  
  17.  
  18. function changeImg() {
  19. holder = document.getElementById("bgHolder");
  20. holder.style.background="url(" + contextPath + imgName[current] + extension + ")";
  21.  
  22. if (current < imgName.length-1) {    current = current+1 }
  23.  
  24. else { current = 1 }
  25.  
  26. setTimeout('randomizeImage()',20000);
  27. }
  28.  
  29.  
Thanks!
Apr 17 '07 #1
6 1066
tpgames
785 512MB
Okay, I think the issue is the body.onload = bit. However, what do I do with the
Expand|Select|Wrap|Line Numbers
  1. window.onload = randomizeImage
bit so that it will do that , without it confusing the poor browser? Disabling it, solves the links not loading in to the iframe problem, but then the images don't work at all.
Thanks!
Apr 17 '07 #2
hi pal,
try this

Expand|Select|Wrap|Line Numbers
  1. setTimeout('randomizeImage()',100);//only is executed on pageload
  2.  
  3. function randomizeImage() {
  4. holder = document.getElementById("bgHolder");
  5. if (holder==null){
  6. setTimeout('randomizeImage()',100);}
  7. else{
  8. changeImg();
  9. }
  10. }
  11.  
  12.  
always works fine for me
peace
Apr 17 '07 #3
tpgames
785 512MB
I've already read quirksmode and don't get it.
Tried
Expand|Select|Wrap|Line Numbers
  1.     <element.onload="initiFrame">
Apr 17 '07 #4
tpgames
785 512MB
forgot to refresh page again. will post again after I try your method. it should work.
Apr 17 '07 #5
tpgames
785 512MB
Thanks! That works!
Apr 17 '07 #6
glad i could help m8 :P
Apr 18 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
41
by: Matt Alanzo | last post by:
Our SOHO 2 person compay sells furniture (not programmers). In '98 we paid $,$$$ for a VBA -Access '97 accounting application, including VBA source code .... an huge investment for us then (and...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
12
by: johannblake | last post by:
First off, I am NOT a beginner. I have lots of experience developing professional web sites and am a professional software developer. Unfortunately I've been out of web site development for the...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
25
by: Peng Yu | last post by:
Hi, It is possible to change the length of "\t" to a number other than 8. std::cout << "\t"; Thanks, Peng
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.