Jump to content

does sel.src work if safari?


sheridan
 Share

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
Link to comment
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.

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...