View previous topic :: View next topic |
Author |
Message |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Fri Jan 23, 2004 1:20 am Post subject: IE and Opera troubles |
|
|
why would this javascript work in Opera but not in IE
Code: |
<SCRIPT LANGUAGE="Javascript">
function image_reload() {
name = "shback";
imgSrc = "backs/"+document.form1.backs.value;
document.form1.text.value = imgSrc;
var x = 300; // width of picture
var y = 100; // height of picture
tag = document.images[name];
img = new Image (x, y);
img.src = imgSrc;
tag.src = img.src;
return;
}
</script>
|
this is what I got so far http://sigs.hopto.org
if you have opera you can see it working..changing the picture when you select a new one
if you have internet explorer 'document.form1.backs.value' doesnt seem to hold any value
thanks for any info |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Jan 23, 2004 9:36 am Post subject: |
|
|
I may not be as smart as you in scripting but I think I know why
your script does not work in IE version 6 , if you install a javascript
in your html file and browse to that file using Internet Explorer , you
will notice when you click on View and than Source at the top that
it will show a javascript type error and I don't know why this shows
but at the top of the code it apears right after the <body> tag.
Code: | <script language="JavaScript">
<!--
function SymError()
{
return true;
}
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
//-->
</script>
|
I have done some research on these errors and how to make my pop up
windows still pop up when these errors show so the code will still work
the real code it self should be in between the <head> section of your html code that way the code will properly execute first instead of the
javascript error it self keeping it from working. Did this fix your problem ? |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Fri Jan 23, 2004 10:30 am Post subject: |
|
|
no, still doesnt work..I moved the javascript but it still shows no value for 'backs' (Should show in the textfield below the listbox as 'backs/selection.png')
I dont see the error your talking about either :?
the error script doesnt show anything.
its driving me mad
I dont know alot about scripting, trying too though. |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Fri Jan 23, 2004 11:21 am Post subject: |
|
|
No errors showing for me in IE6, but the script isn't working. If you type the value manually in in IE it shows the image for a second and then blinks back to the red x / missing image. I'm assuming OnChange is handled slightly differently in IE to Opera... Have you tried it in Mozilla? |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Fri Jan 23, 2004 5:53 pm Post subject: |
|
|
havent tried mozilla...
the textfield in the script should show the path
Code: |
mgSrc = "backs/"+document.form1.backs.value;
document.form1.text.value = imgSrc;
|
in opera if I have 'red.gif' selected in the listbox that textfield shows
'backs/red.gif'
in IE it only shows
'backs/' |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Fri Jan 23, 2004 6:27 pm Post subject: |
|
|
Broken in Mozilla too... Either Opera is being too generous with some handling of that onchange or IE and Moz are being too harsh... |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Fri Jan 23, 2004 6:37 pm Post subject: |
|
|
sorry, im not good with explanations
I dont think it has a problem with the actual image changing because if I hardcode it as what it should be it works fine.
more clarification:
what is the correct way to get the current selection from a listbox called 'backs'?
i've got
bla = "backs/"+document.form1.backs.value;
and I also tried
bla = "backs/"+form1.backs.value;
in IE (and mozilla) it only shows blah as 'backs/' |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Fri Jan 23, 2004 7:02 pm Post subject: |
|
|
For it to work in Mozilla :
imgSrc = "backs/"+document.form1.backs.value;
document.form1.text.value = imgSrc;
But that fails in Opera and IE... Not found a universal one yet - perhaps you'll need browser detection ? |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Fri Jan 23, 2004 7:39 pm Post subject: |
|
|
added mozilla(netscape 1989 feel eh?) to my every growing library of browsers
it all works in mozilla and opera now but still not IE
edit:
got it! the problem was i never added a value= to the <options>
stupid simple me looking in all the wrong places :roll:
thanks for the assists |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sat Jan 24, 2004 2:57 am Post subject: |
|
|
Yeah it works ! How do you create such scripts , I have a javascript book and mine can't teach me that cool script you made , what is the secret. ? |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Sat Jan 24, 2004 4:05 am Post subject: |
|
|
hehe secret? i search google for what i want to do, find examples then tear them apart. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sat Jan 24, 2004 4:25 am Post subject: |
|
|
Kind of the same for me lol :oops:
I try the stuff on my own first |
|
Back to top |
|
 |
jtc970 -
Joined: 24 Mar 2003 Posts: 172
|
Posted: Sat Jan 24, 2004 5:05 am Post subject: |
|
|
I tried books but I found out I was finding the answer more often on the web...
For me its easier to learn it by seeing the script, knowing what it does then going through the code line by line to see how it does it.
nothing to :oops: about. lol |
|
Back to top |
|
 |
|