Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
RE: Possible JavaScriptCore problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Possible JavaScriptCore problem?



The work around is to use the mousedown event instead of click.
-----Original Message-----
From: Andrew Lippert
Sent: Wednesday, March 30, 2005 1:20 PM
To: 'email@hidden'
Subject: Possible _javascript_Core problem?

I am working on creating a synthetic event in Safari (this fails in both 1.2.X and 2.0 beta). I am attempting to call the onclick event handler on an image with an id of "image1". The following code successfully dispatches the event on Firefox and Mozilla, but fails on Safari. The expected behavior is for the alert to be displayed when the page loads, or anytime the image is clicked.

 

Am I doing something wrong, or is this mechanism broken?

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>Test Safari dispatchEvent method</title>

<script language=_javascript_>

function getObj(name) // cross browser capable object reference retriever

{

      if (document.getElementById)

      {

            this.obj = document.getElementById(name);

            this.style = document.getElementById(name).style;

      }

      else if (document.all)

      {

            this.obj = document.all[name];

            this.style = document.all[name].style;

      }

      else if (document.layers)

      {

            this.obj = getObjNN4(document,name); // this function is not included as it is irrelevant

            this.style = this.obj;

      }

}

 

function clicked()

{

      alert("Image Clicked.");

}

 

window. ()

{

      var clickImage = new getObj("image1");

      var >

      onClickEvent.initEvent("click", true, true);

      clickImage.obj.dispatchEvent(onClickEvent);

};

</script>

 

</head>

<body>

<img id=image1 src="" >

</body>

</html>

 

Andrew Lippert

Vice President of Engineering

 

Apex Learning

315 5th Ave. South, Suite 600

Seattle, WA 98104

 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webcore-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

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 © 2011 Apple Inc. All rights reserved.