Jump to content
sheridan

does sel.src work if safari?

Recommended Posts

I am trying to finalise a co-creation website that swaps image when certain radio buttons are selected. It works in Firefox.. can anyone tell me why it is not working in Safari?
The part that I feel does not connect is as below:
}
var sel = document.getElementById("mainimg");
var s = grps+"";
while (s.length < 5) s = "0" + s;
}
function addmodelid() {
var textbox = document.getElementById("item_number");
var mainimg = document.getElementById("mainimg");
var s = mainimg.src
textbox.value = s.substring(71);
return true;
}
</script>
<div id="columns">
<div class="right column">
<p><img title="Fudged Skins" id="mainimg" alt="mainimg" src="http://www.designpartners.co.uk/resources/iPhone-skins/skin-options/iPhone_Skins_Art_Case02000.png" height="480" width="380" border="0" onsubmit="return addmodelid()"(mainimg)>
Edited by sheridan

Share this post


Link to post
Share on other sites

What's that "(mainimg)" doing inside the img tag?

 

It takes several seconds to download each image after clicking on the button, are you just not giving it enough time in Safari? I don't have Safari installed but it uses the same engine as Chrome so I'm testing it in Chrome. Otherwise, open the error console in Safari to check for Javascript error messages.

Share this post


Link to post
Share on other sites

No it definitely not working on iPadI played with src in w3schools tryit pages and was able to get it to work fine, so it's not a support issue.Try alerting sel.src immediately after setting it. See if safari is messing with it behind your back. Still doesn't explain why the image isn't breaking on my end though. I mean if the URL is invalid safari should show the broken img icon. Other possibilities could be a caching problem ( safari might think it hasn't actually changed even if src did. add on a ?rand=rand() at the end or something similar) or lack of preventDefault ( unsure if that would matter here). It might even be that (mainimg) you have stuck in the attributes and safari could fail to parse it.

  • Like 1

Share this post


Link to post
Share on other sites

Is onchange event correctly used? I thought is was for form elements such as select and input elements radio ( even though i think there a problem in safari using onchange, where onclick should be used instead) and checkbox, not a td element.

  • Like 1

Share this post


Link to post
Share on other sites

Simples:The sel.src function was not changing the image file name in Safari - which was evident in the paypal post... so I knew it was not a cache problem... ! But I didnt know that Safari doesnt like onchange - it does like onclick though!!!!

 

Sacred is true.

 

Thanks!

Edited by sheridan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...