The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> 2 javascripts, 1 html document, Some kind of conflict ?
anders
post Oct 16 2007, 01:18 PM
Post #1





Group: Members
Posts: 5
Joined: 4-October 07
Member No.: 3,982



Hi.

A long story short:

I'm using a CSS dropdown menu I found here
http://www.dynamicdrive.com/dynamicindex1/chrome/index.htm

... This is a .js which loads just fine, and works properly.

I'm also using a second .js which ain't working that well. The .js contains the following code:
CODE
function openOtherLinks(id1, id2) {
  var link1 = document.getElementById(id1);
  var link2 = document.getElementById(id2);
  if(!link1.href || !link2.href)
      return;
  self.frames['left'].location.href = link2.href;
  self.frames['main'].location.href = link1.href;
}


And the html heading contains among other things these lines:
CODE
<script type="text/javascript" src="java/meny.js"</script>
<script type="text/javascript" src="java/links.js"</script>

Where links.js contains the code i wrote above.

The links-script makes me able to make a "<a href" opening two targets at once, with each their targets (which in this case would be iframes).
Making parts of my html like this:
CODE

<a href="java script: openOtherLinks('rotel1', 'rotel2')">Rotel</a>
<a href="java script: openOtherLinks('tannoy1', 'tannoy2')">Tannoy</a>

... And the following anywhere outside the body:
CODE
<a id="tannoy1" href="tannoy_overview.html"></a>
<a id="tannoy2" href="tannoy_left.html"></a>
<a id="rotel1" href="rotel_overview.html"></a>
<a id="rotel2" href="rotel_left.html"></a>


Two examples of combinations I've trid:
http://www.risington.no/dynamikk/
- This one contains the links-script in the heading, and loads the dropmenu from the .js, which works out just fine in mozilla firefox and safari but NOT explorer. Tried out both 6.xx and 7.

http://www.risington.no/dynamikk/index2.html
- This one loads both the scripts external. But here the a href-part suddenly seems to be getting a slight problem. I'd believe it would be because of that the a hrefs is directed straight to a couple of tags in the script itself. But I'm far from no brain surgent when it comes to these kind of things.

1. Should the .js look different ? Or is this correct ?

2. Whenever I put the code in links.js directly in the heading of the html, it works but then it screws up the menu-script when the page is viewed in Explorer. (which was my problem at first).

3. Any ideas of how I could combine these scripts? Does it matter if I'm using them seperatly as .js-files or if I'm just putting it all directly into the heading? Is it ok to load one as an external js, as I put the other one in the heading?

Any help here would be awesome :=)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 07:47 AM