[SOLVED] Javscript broken in IE 6 (but nothing else, it would seem)...

This is a discussion on "[SOLVED] Javscript broken in IE 6 (but nothing else, it would seem)..." within the JavaScript Forum section. This forum, and the thread "[SOLVED] Javscript broken in IE 6 (but nothing else, it would seem)... are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 30th, 2008, 09:42
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 108
Thanks: 2
Thanked 1 Time in 1 Post
[SOLVED] Javscript broken in IE 6 (but nothing else, it would seem)...

So what's new, I hear you cry. In the interests of not looking like an incompetent buffoon in front of the surfers out there who don't know any better than to use IE, could someone please help me out with making my javascript code IE 6 - friendly?

Here is my site:
http://www.jonathanmortimer.co.uk/test2

Have a look around, you'll probably soon discover where the problems are (I cannot see them as I don't have IE, but I have been informed that they are mainly on the bottom row of icons).

This site works perfectly in Safari and Firefox, although it is not 100% complete yet.

Thanks for your help!
Reply With Quote

  #2 (permalink)  
Old Mar 30th, 2008, 10:37
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Quote:
Originally Posted by jonnymorris View Post
(I cannot see them as I don't have IE...).
Then get it. Sadly, IE 6 & 7 are essential software for web designers.

Multiple IEs
Reply With Quote
  #3 (permalink)  
Old Mar 30th, 2008, 12:33
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 108
Thanks: 2
Thanked 1 Time in 1 Post
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Quote:
Originally Posted by MikeHopley View Post
Then get it. Sadly, IE 6 & 7 are essential software for web designers.

Multiple IEs
Fortunately Microsoft no longer make IE for Mac OS X.
Reply With Quote
  #4 (permalink)  
Old Mar 30th, 2008, 12:52
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,012
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Yes, IE 6 is certainly struggling with this. You should really make the most of the DOM here.

Instead of using inline event handlers, use a for loop to cycle through your links and apply the onclick event when the DOM is ready.

And instead of innerHTML, use appendChild. IE6 has excellent DOM Level 1 support, and using this sort of practice should greatly increase the chances of compatibility.
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #5 (permalink)  
Old Mar 30th, 2008, 13:05
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 108
Thanks: 2
Thanked 1 Time in 1 Post
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Quote:
Originally Posted by aso186 View Post
Yes, IE 6 is certainly struggling with this. You should really make the most of the DOM here.

Instead of using inline event handlers, use a for loop to cycle through your links and apply the onclick event when the DOM is ready.

And instead of innerHTML, use appendChild. IE6 has excellent DOM Level 1 support, and using this sort of practice should greatly increase the chances of compatibility.
I'm not terribly good with javascript, it has to be said, and it's years since I did any C programming (which I wasn't very good at). Any help on the for loop, how to cycle through the links, and what DOM parts I should be looking at?
The code I have was written by someone else, I'm not even sure how that works.
Reply With Quote
  #6 (permalink)  
Old Mar 30th, 2008, 13:31
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,012
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

I'll try and write up something later. For now I recommend reading up on W3Schools Javascript tutorials.

Even if you're still not sure how to write the script, you'll get to grips with the syntax and methods
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #7 (permalink)  
Old Mar 30th, 2008, 14:51
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,012
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

OK Jonny, I've got something

I've used a script from Jeremy Keith in his book 'DOM Scripting' (which is a great read for learning Javascript) and modified very slightly (plus commented it too).

First, get rid of all the onclick handlers in your markup, and set the href of the link to your target image. Your #thumbs section should look like this;
HTML: Select all
<div id="thumbs">
    <a href="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_neyedc.png" title="NEYEDC Logo">
    <img width="97" height="76" alt="Logo - NEYEDC" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_neyedc.png"></a>

    <a href="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_leaflet1.png" title="NEYEDC Leaflet">
    <img width="97" height="76" alt="Leaflet - NEYEDC" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_leaflet.png"></a>

    <a href="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_garage1.png" title="Garage Photomanipulation">
    <img width="97" height="76" alt="Photomanip - Garage" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_garage.png"></a>
    
    <a href="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_trees1.png" title="Trees">
    <img width="97" height="76" alt="Photomanip - Trees" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_trees.png"></a>
                    
    <a href="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_goodieshoes.png" title="Goodie New Shoes">
       <img width="97" height="76" alt="Goodie New Shoes" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_goodieshoes.png"></a>
</div>

<p id="desc">NEYEDC Logo</p>
Important!: Change the name attribute of your main image to an id, and change your paragraph id description to desc, like so;
HTML: Select all
<img id="mainimage" src="http://www.jonathanmortimer.co.uk/test2/images/graphic_main_neyedc.png" alt="Main image"/>
...
<p id="desc">NEYEDC Logo</p>
Now link to the attached script in the <head> using;
HTML: Select all
<script type="text/javascript" src="path/to/script.js"></script>
Please do read through the script and try to understand what it's doing If you have any queries please ask.

NOTE: I don't usually do this sort of thing, but since I'm learning it myself it's useful for me to practice whenever possible!


Please rename file extension to .js (EDIT: modified 18:39 GMT 30/03/08)
Attached Files
File Type: txt gallery.txt (2.2 KB, 1 views)
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)

Last edited by Aso; Mar 30th, 2008 at 17:41. Reason: Changed due to IE6 bug
Reply With Quote
  #8 (permalink)  
Old Mar 31st, 2008, 16:27
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 108
Thanks: 2
Thanked 1 Time in 1 Post
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Thanks muchly! This does the trick for IE 6 at least, and still works for Firefox and Safari.

One thing though.. it does not change the link tag that surrounds the main image. Reading through the js code, presumably I could add this in by getting the link perhaps from an id contained in the <a> tag for each thumb and set that to be the main image link using the same method that was used to set the image?

I'm not sure what everything in the js code does or how it works, it would be a case of best guess, trial and error for me. Wish me luck!
Reply With Quote
  #9 (permalink)  
Old Mar 31st, 2008, 17:27
Reputable Member
Join Date: Jul 2007
Location: UK
Posts: 108
Thanks: 2
Thanked 1 Time in 1 Post
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

BY JOVE I'VE DONE IT!!! Hold on, let me check that I wasn't dreaming... *pinch* OW!

With the very much appreciated javascript functions provided by you, of course

It now allows a through-click on the main image (but only in the photo and web categories, I used your original js code for the graphics one as I don't want through-clicks there). I just need to create a couple more pages in my large image set and that part of it will be complete.. unless there's a way to detect when the name="" attribute is empty and not set the corresponding attribute, hmm...


I'm a bit of a slow learner when it comes to programming I'm afraid, though if I think about it long enough and come back to it later, it will sink in eventually.
Reply With Quote
  #10 (permalink)  
Old Mar 31st, 2008, 17:28
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,012
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Javscript broken in IE 6 (but nothing else, it would seem)...

Glad to hear it!

Keep up the learning
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
I have literally broken FireFox Stormraven Webforumz Cafe 6 Jun 10th, 2008 17:45
Photoshop broken! *screams* CloudedVision Graphics and 3D 1 May 17th, 2008 22:04
Redirect broken links Oak Search Engine Optimization (SEO) 8 Apr 18th, 2008 21:09
Video's are broken :( Stormraven Webforumz Cafe 5 Mar 15th, 2008 11:34
Dreamweaver - Broken Links mark_88_turbo Graphics and 3D 5 Apr 8th, 2005 08:34


All times are GMT. The time now is 19:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43