cyber0ne Posted December 19, 2005 Share Posted December 19, 2005 I'm testing some JavaScript for something I want to implement on my website, and I'm noticing a cross-browser issue with the following:function PreviewImage(stringPreview, stringPhoto){ document['photopreview'].src = stringPreview; document.links['photopreviewlink'].href = stringPhoto;}Everything works great in Firefox and Opera, but IE doesn't like that second line in the function. It claims that "document.links.photopreviewlink is null or not an object." For reference, the line of HTML being changed by this code is:<a name="photopreviewlink" href="test.jpg"> <img name="photopreview" src="testpreview.jpg"></a>And the line calling the function is:<a href="java script:PreviewImage('test2.jpg', 'test2preview.jpg');"> <img src="test2thumb.jpg"></a>Is there a way to achieve this functionality in IE without breaking it in other browsers?-cyber0nehttp://www.cyber0ne.com Link to comment Share on other sites More sharing options...
aspnetguy Posted December 19, 2005 Share Posted December 19, 2005 change <a name="photopreviewlink" href="test.jpg"> to <a name="photopreviewlink" href="test.jpg" id="photopreviewlink"> then change function PreviewImage(stringPreview, stringPhoto){document['photopreview'].src = stringPreview;document.links['photopreviewlink'].href = stringPhoto;} to function PreviewImage(stringPreview, stringPhoto){document['photopreview'].src = stringPreview;document.getElementById('photopreviewlink').href = stringPhoto;} this should work in all browsers. Link to comment Share on other sites More sharing options...
cyber0ne Posted December 19, 2005 Author Share Posted December 19, 2005 Much better, thanks!-cyber0nehttp://www.cyber0ne.com Link to comment Share on other sites More sharing options...
aspnetguy Posted December 19, 2005 Share Posted December 19, 2005 your welcome...hey I like the monkey on your site.Is it the evil monkey from Family Guy? lol Link to comment Share on other sites More sharing options...
cyber0ne Posted December 19, 2005 Author Share Posted December 19, 2005 your welcome...hey I like the monkey on your site.Is it the evil monkey from Family Guy? lolĀ <{POST_SNAPBACK}> There are several iterations of the evil monkey in Chris' closet in that rotation, along with a bunch of other pictures :)Don't get too used to that website, though. That's precisely what I'm working on is a _major_ re-write of that whole thing.-cyber0nehttp://www.cyber0ne.com Link to comment Share on other sites More sharing options...
aspnetguy Posted December 19, 2005 Share Posted December 19, 2005 ok..i still like the monkey. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now