Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: window.onload not working in xhtml



I'll re-iterate it's working on my machine also under xhtml. I would confirm in your text editor that your file actually is utf-8 encoded, as I've seen encoding issues cause js problems in the past.

Niels

On Feb 28, 2006, at 6:45 PM, Andrew Sorensen wrote:

Hi Jakub,

Thanks for the test run :)

I've finally checked how your code works in Safari 2.0.3 (sorry for the delay - unfortunately I work on a Mac only at home).
Surprisingly the code seems to work as expected.
Changing the DOCTYPE to html, xhtml strict and xhtml transitional gives always the same result.
Hmm, that's strange, definitely does not work on my machine.

IMHO there may be a problem in your Safari configuration, rather than in the code.
First of all, please open the Safari preferences, go to the "Security" pane and check if JavaScript is enabled.
Yep, it is enabled and is loading the script OK. (works fine if doing an alert for example).

If JavaScript is enabled, you may try to add such a line to the 'mytest.js' file:
alert("test");
and re-run the page.
When the script is being loaded the appropriate message should be shown.
Yep, this works as expected.

You may also try to enable the Safari Debug menu and get yourself familiar with the Safari developer tools.
Check this site for details: http://developer.apple.com/internet/ safari/faq.html
Done.

Hope this will help.
Let us know how it's going.
Still not working :(

Oh well, I've given up on XHTML and have dropped back to HTML where everything works as expected.

Thanks for your help.


Regards,
Jakub

On Feb 28, 2006, at 1:10 AM, Andrew Sorensen wrote:


On 27/02/2006, at 6:41 PM, Jakub Pawlowicz wrote:

Hi Andrew,

Have you noticed that your code is not valid XHTML?
There's an unnecessary '-->' string in line which begins with '<html'
You can check it out at http://validator.w3.org/.


IMHO there lies the problem.
Hope this helps.

On Mon, 27 Feb 2006 18:28:21 +1000, Andrew Sorensen wrote
Hi everyone,

window.onload doesn't seem to work in safari 2.0.3 when using xhtml
(not sure about earlier versions).
The example below works fine when using html but does nothing when
using xhtml.


I should add that the xhtml version works fine in mozilla.

-------------------------------------- mytest.xhtml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> -
-> <head> <meta http-equiv="Content-Type" content="text/ html;
charset=utf-8"/> <title>My Test</title> <script
type="text/javascript" src="mytest.js"/> </head> <body> <p>A
Hello World</p> </body> </html>


-------------------------------------- mytest.js file

function myfunc()
{
     window.alert("HELLO WORLD");
}

window.onload = myfunc;

--------------------------------------

_______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.