/    Sign up×
Community /Pin to ProfileBookmark

simple safari/opera compatibility problem – help

Hi – I have two simple problems. I have an onLoad function which works fine in IE and opera but not in safari. I also have an onClick function which only works in IE.

The onLoad function is called from the body tag like so –
<body onLoad=”preloadImages();”> – I don’t think the problem is within the function as I have read that safari requires slightly different coding.

The second issue occurs in both safari and opera. Here I am using an onClick to run a function which sets two global variables. –
<td><img src=”images/image1.jpg” onClick=”goto(‘page2.htm’,1)”></td>

function goto(a,b){
page = a; esc = b;
if(c==48){esc=0;window.open(page,”_self”)}};

The idea is that onClick “var esc” is set to 1 which halts another function and then a new page is opened. Once again I am sure the function is not the problem.

If you have any idea how to correctly code the onLoad and/or onClick or know of a good tutorial etc it would be much appreciated.

Cheers

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 06.2004 — 1.onload

Try this

<script>

....

code here

....

....

window.onload=preloadImages;

</script>

2.onclick

try this

<a href="#" onclick="goto('page2.htm',1);return false"<img src="images/image1.jpg" border="0">
Copy linkTweet thisAlerts:
@KorMay 06.2004 — sorry, mistyping. Correct is:

<a href="#" onclick="goto('page2.htm',1);return false"><img

src="images/image1.jpg" border="0"></a>
Copy linkTweet thisAlerts:
@screamingWeaselauthorMay 06.2004 — The onClick issue in Opera is now solved but Safari still isn't interested in either the onLoad or onClick events. Safari does register the "<a href>" tag but just doesn't send the relevant info through to the the function onClick.

So at this point I am still looking for an answer.

Thanks all.
Copy linkTweet thisAlerts:
@screamingWeaselauthorMay 06.2004 — I have just got the onClick event to work in Safari. I did this by changing the name of the goto function. I have a feeling goto must be a reserved word in the safari world. Still can't get the onLoad to work.
Copy linkTweet thisAlerts:
@screamingWeaselauthorMay 07.2004 — I put the onLoad back inside the body tag and it works fine. The whole mess was the result of using "goto" as a function name. I have just done a quick check and found that it is indeed a javascript reserved word, one day it may even be used.

For a list of all reserved words have a look at

http://www.quackit.com/javascript/javascript_reserved_words.cfm

I really should have known better and used a more complex function name.

Hope this helps someone

See ya
Copy linkTweet thisAlerts:
@KorMay 07.2004 — as javascript is case sensitive, a good practice is to use some Upper case letters, even in/with reserved words

function goTo()

function closeWin()

function inQ()

function openWin()
Copy linkTweet thisAlerts:
@screamingWeaselauthorMay 08.2004 — Thanks again Kor, your suggestion makes good sence. I would just like point out here that my comment in my last post where I said safari doesn't like the window.onLoad function was incorrect. It works fine, I just mistyped it.

Thanks again for all the help.
×

Success!

Help @screamingWeasel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...