HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 10th, 2003, 02:48 PM
blursotong blursotong is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 45 blursotong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
How to simulate click action in N6?

I'm trying to simulate a click action upon completion of some tasks, so as to bring user back to the default page. The following codes work in IE5.5+, but not in N6+, what could be the problem? Is .click() supported in N6+?

function setDefaultPage() {
simulateAnchorClick(document.anchors[0]);
}

function simulateAnchorClick(anchor) {
anchor.click();
}

Reply With Quote
  #2  
Old June 10th, 2003, 06:00 PM
jerom jerom is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Posts: 1,014 jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 19 h 32 m 47 sec
Reputation Power: 9
It's a bug in Mozilla. click() works for a number of form elements, but not yet for anchors.

Here's a workaround:
location.href = anchor.href

Hope this helps,
Jeroen

Reply With Quote
  #3  
Old June 10th, 2003, 08:07 PM
jkd jkd is offline
CF sMod
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Maine, USA (a.k.a. Boonies)
Posts: 242 jkd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 43 sec
Reputation Power: 9
Send a message via ICQ to jkd Send a message via AIM to jkd Send a message via Yahoo to jkd
Not a bug:
http://www.w3.org/TR/2003/REC-DOM-L...tml#ID-48250443

See a click() method anywhere? Didn't think so.

However, because Mozilla has such excellent standards support, you can give anchors a click method yourself:

HTMLAnchorElement.prototype.click = function() {
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}

Reply With Quote
  #4  
Old July 9th, 2003, 03:25 AM
blursotong blursotong is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 45 blursotong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Jerom and jkd, I'm so grateful for your replies. Somehow I missed your replies till now

I like both ideas However, I'm not quite sure how to implement them...

1) Jerom
Do you have sample codes with reference to my example above?

2) jkd
Where can I put that piece of code in? How to call/use it? A little lost here.

Reply With Quote
  #5  
Old July 9th, 2003, 07:32 AM
jerom jerom is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Posts: 1,014 jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level)jerom User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 19 h 32 m 47 sec
Reputation Power: 9
The solution posted by jkd is superb. Use it!
You just need to make sure that any Mozilla based browser loads his code before using any anchor based click method.

Jeroen

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > How to simulate click action in N6?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT