473,770 Members | 5,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Severe Javascript collision

I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.

I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.

When the popupwin.js file is by itself, all anchors with rel="external"
and an external address (http://...) work just fine, spawning windows
just as required. When I add the toggle.js file, it works properly, but
causes the popupwin.js file to stop working completely. Why? How can I
correct this?

Below are the two files:

<!--start popupwin.js -->
function popWin(){
if (!document.getE lementsByTagNam e) return;
var a = document.getEle mentsByTagName( 'a');
var agt = navigator.userA gent.toLowerCas e();
var is_ie = ((agt.indexOf(" msie") >= 0) && (agt.indexOf("o pera") == -1));
for (var i=0; i<a.length; i++){
if ((is_ie) && (a[i].getAttribute(' href') != null) &&
(a[i].getAttribute(' href').indexOf( "://") >= 0) &&
(a[i].getAttribute(' rel') == "external") &&
(a[i].getAttribute(' href').indexOf( "/check/referer") >= 0)){
a[i].target = '_blank';
a[i].title += ' (opens in new window)';
}
else if ((a[i].getAttribute(' href') != null) &&
(a[i].getAttribute(' href').indexOf( "://") >= 0) &&
(a[i].getAttribute(' rel') == "external") ) {
a[i].title += ' (opens in new window)';
a[i].onclick = openWin;
a[i].onkeypress = openWin;
}
}
}
function openWin() {
var url = this.href;
var target = '_blank';
var options = 'top=' + (screen.availHe ight/2-250) + ',left=' +
(screen.availWi dth/2-400) +
',outerwidth=80 0,outerheight=5 00,menubar=no,t oolbar=no,locat ionbar=no,perso nalbar=no,direc tories=no,statu sbar=no,scrollb ars=yes,resizab le=yes';
window.open(url ,target,options );
return false;
}
window.onload = popWin;
<!--end popupwin.js-->


<!--start toggle.js-->
function toggleNext(el,t name,first) {
var next=el.nextSib ling;
var tags=el.parentN ode.getElements ByTagName(tname );
while(next.node Type != 1) next = next.nextSiblin g;
next.style.disp lay=((next.styl e.display=="non e") ? "block" : "none");
if (first!=1){
for (i=0; i<tags.length; i++) {
var tohide=tags[i].nextSibling;
while(tohide.no deType != 1) tohide = tohide.nextSibl ing;
if (tohide!=next){ tohide.style.di splay="none";}
}
}
}
function toggleNextByIdA ndTag() {
var ccn="focus";
clickers=docume nt.getElementBy Id("toggle").ge tElementsByTagN ame("dt");
for (i=0; i<clickers.leng th; i++) {
clickers[i].className+=" "+ccn;
clickers[i].onclick=functi on() {toggleNext(thi s,"dt")}
toggleNext(clic kers[i],"dt",1);
}
}
window.onload=t oggleNextByIdAn dTag;
<!--end toggle.js-->
Thanks for any help.
....Geshel
--
*************** *************** *************** *************** *********
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send any e-mail to my first name at my last name dot org.
*************** *************** *************** *************** *********
Jan 18 '07 #1
4 2018


On Jan 18, 4:13 am, Neo Geshel <got...@geshel. orgwrote:
I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.

I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.

When the popupwin.js file is by itself, all anchors with rel="external"
and an external address (http://...) work just fine, spawning windows
just as required. When I add the toggle.js file, it works properly, but
causes the popupwin.js file to stop working completely. Why? How can I
correct this?

Below are the two files:

<!--start popupwin.js -->
[snip]
>window.onloa d = popWin;
<!--end popupwin.js-->

<!--start toggle.js-->
[snip]
>window.onload= toggleNextByIdA ndTag;
<!--end toggle.js-->
The last "window.onl oad = function" overwrites the first one.

Here's a TIP someone made that might help you.
http://blog.firetree.net/2005/07/17/javascript-onload/
>
Thanks for any help.
...Geshel
I tried anyways, hope the link helps.

// Switchable

Jan 18 '07 #2
[on] wrote:
>
On Jan 18, 4:13 am, Neo Geshel <got...@geshel. orgwrote:
>I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.

I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.

When the popupwin.js file is by itself, all anchors with rel="external"
and an external address (http://...) work just fine, spawning windows
just as required. When I add the toggle.js file, it works properly, but
causes the popupwin.js file to stop working completely. Why? How can I
correct this?

Below are the two files:

<!--start popupwin.js -->

[snip]
>window.onloa d = popWin;
<!--end popupwin.js-->

<!--start toggle.js-->

[snip]
>window.onload= toggleNextByIdA ndTag;
<!--end toggle.js-->

The last "window.onl oad = function" overwrites the first one.

Here's a TIP someone made that might help you.
http://blog.firetree.net/2005/07/17/javascript-onload/
Actually, when I implemented the code suggested by the link, none of my
scripts work. I still believe that I am experiencing a JS collision somehow.

I am far from an expert on Javascript. Can a script in one external JS
file affect a script in another external JS file? Can JS scripts in
different external files communicate with each other?

TIA
....Geshel
--
*************** *************** *************** *************** *********
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send e-mail to my first name at my last name dot org.
*************** *************** *************** *************** *********
Jan 18 '07 #3
Lee
Neo Geshel said:
>
[on] wrote:
>>
On Jan 18, 4:13 am, Neo Geshel <got...@geshel. orgwrote:
>>I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.

I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.

When the popupwin.js file is by itself, all anchors with rel="external"
and an external address (http://...) work just fine, spawning windows
just as required. When I add the toggle.js file, it works properly, but
causes the popupwin.js file to stop working completely. Why? How can I
correct this?

Below are the two files:

<!--start popupwin.js -->

[snip]
>>window.onlo ad = popWin;
<!--end popupwin.js-->

<!--start toggle.js-->

[snip]
>>window.onload =toggleNextById AndTag;
<!--end toggle.js-->

The last "window.onl oad = function" overwrites the first one.

Here's a TIP someone made that might help you.
http://blog.firetree.net/2005/07/17/javascript-onload/

Actually, when I implemented the code suggested by the link, none of my
scripts work. I still believe that I am experiencing a JS collision somehow.

I am far from an expert on Javascript. Can a script in one external JS
file affect a script in another external JS file? Can JS scripts in
different external files communicate with each other?

The scripts are not executing in different external files.
They are each loaded into the current page environment and then executed.

They're very clearly colliding in the definition of the
window.onload function. One solution is to define a new
function that calls both of those functions and invoke that
new function as your onload event handler:

function invokeBoth() {
popWin();
toggleNextByIdA ndTag();
}
window.onload=i nvokeBoth;

--

Jan 18 '07 #4
Neo Geshel wrote:
Actually, when I implemented the code suggested by the link, none of my
scripts work. I still believe that I am experiencing a JS collision
somehow.

I am far from an expert on Javascript. Can a script in one external JS
file affect a script in another external JS file? Can JS scripts in
different external files communicate with each other?
Actually, I have solved the issue. Unfortunately, the linked suggestion
wasn’t it... it simply didn’t work for me.

What I did was look at a third script, one that has never failed me...
nav.js, my script for turning a <ulinto an expandable navigational
menu (a very slick thing once combined with a generous dollop of CSS!).
This script used the following method to launch itself:

function WindowOnLoad(ob j, evType, fn){
if (obj.addEventLi stener){
obj.addEventLis tener(evType, fn, false);
return true;
} else if (obj.attachEven t){
var r = obj.attachEvent ("on"+evType , fn);
return r;
} else {
return false;
}
}
WindowOnLoad(wi ndow, "load", makeTreesC);

So what I did was extract that function into a separate JS file (just to
keep things clean!) and used that same method of calling it across all
three scripts. And upon uploading and page refresh... voil*, all my
scripts worked. YAY!

One final wrinkle, though. Even though they all work, IE7 throws an
error... there is the yellow warning symbol and “Error on page” on the
left side of the status bar, when double-clicked it brings up the
console that provides an “Object doesn’t support this property or
method” error. All the scripts still work, though, so I don’t know what
is up. =( Hell, IE doesn’t even tell me which script is the culprit!

Thanks for all the help, as the suggested article actually sent me on
the right path.
...Geshel
--
*************** *************** *************** *************** *********
My e-mail address is an automatically monitored spam honeypot. Do not
send e-mail there unless you wish to be reported as a spammer. Please
send e-mail to my first name at my last name dot org.
*************** *************** *************** *************** *********
Jan 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3316
by: Dave | last post by:
Hi folks, I am trying to develop a routine that will handle sphere-sphere and sphere-triangle collisions and interactions. My aim is to develop a quake style collision engine where a player can interact with a rich 3D environment. Seem to be 90% of the way there! My problems are related to calculations where the result tends to zero (or another defined limit.) Have loads of cases where this kind of interaction occurs but this one
2
2422
by: MStepansky | last post by:
Any ideas of some of the good Javascript books that involves graphics programming: - to be able to move the images pixelwisely. - to be able to grab an image and move it around on screen (on top of other images behind it) and drop it. - to be able to scroll the window pixelwisely, horizontally or vertically.
4
1755
by: Brian Basquille | last post by:
Hello all, Well, we've gotten to it: the real meaty area of my Air Hockey game.. Any help or suggestions for the following would be much appreciated. In plain terms: My paddle needs to be able to strike the puck and move in the direction opposite to which it was struck (a simple collision, basically!)
2
1244
by: Dave Brown | last post by:
I believe I have found a severe limitation of DotNet, with respect to hosting Windows Form Controls in WebPages. It appears this is only possible when the web is configured on Port 80. Any other port and the control will not display. After a couple of days of searching the newsgroups/various forums I have found other postings requesting information on this anomaly yet nobody has found a solution. What are Microsoft doing with this ? It...
4
2763
by: king | last post by:
I have an application which links to a 3rd-party shared library(say a) and dlopens another one(say b). And each of those 3rd party shared libraries requires another shared library respectively(say c &d). I am facing a problem that there is a symbol collision between the shared libraries c & d which is causing problem for me MyAPP------links----a.so -----------requires----->c.so |----------dlopens------>b.so---------requires------->d.so ...
5
1754
by: Cloy | last post by:
The script below loads a calendar page in an iframe and scrolls to today's date. It works just dandy on my apache/linux server, but won't do anything when I use IIS. (Nothing appears on the page at all where the script is at.) I'd appreciate any suggestions on how to make this work from the IIS server.
2
1996
by: The87Boy | last post by:
Hey I have a problem with a Javascript, which doesn't works in Firefox You can have a mouse over the 2 first pictures, but after the second picture has moved over the screen, nothing is happening when you move the mouse over the slideshow The source code is here: http://the87boy.dk/Slideshow.html What could be wrong?
0
2170
by: licombo | last post by:
I am making a flash game which is similar to the classic game Asteroids. I am stuck in the final step of the game where I have to make the collision detection working before the whole game is functioning.. My problem is I cannot figure it out how can I make the collision detection working in my game..because those asteroids are coded to appears on the stage every five seconds from the library, so I cannot give the asteroids an instance name...
1
9564
by: May Amor | last post by:
Helu gurus!!! I have a code below about hashing method with collision resolution...My problem is how to use the collsion resolution again if the hash index though has already a value. Please kinda help me with this..I want to determine also if the table now is full so as to stop user from entering a key. size of the table=19, Thanx a lot..GodBless ________________________________________________ #include<iostream.h> #include<conio.h> ...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.