Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

safari .click()

Status
Not open for further replies.

www2004

Programmer
Aug 11, 2004
15
US
in my mobile site...during a postback, server code assigns a variable to a telephone number. upon page load, i call a js function that finds a hyperlink on my form, assigns the href attribute to dial the telephone number and calls .click() on the hyperlink. this is not working in safari. here is the js code:

function ExecuteTelephony(){
var sURL = "<%=ExecuteTelephony%>"
if (sURL != "" && sURL != "undefined"){
var o = document.getElementById('ctl00_lnkOpenHyperlink')
if (o) {
o.href = sURL;
o.setAttribute("href",sURL);
o.click();
}
return true;
}
return false;
}


"<%=ExecuteTelephony%>" calls a server side method that returns a string that looks like "tel:8003459999". in my non-mobile site, i use the same methodology to initiate a skype call. it is working in IE, this is the only supported browser in our non-mobile site. from what i've seen in my safari testing, the hyperlink's href attribute is being set correctly (i can click the link after the page loads), so I think the problem lies in the o.click() line.

if this is the problem, is there a way to solve it in safari? in other mobile browsers? my goal is to support the ability to postback, set a server variable, and upon page reload initiate a call to the number set in that server variable.

i greatly appreciate any input on this...i'm stumped!
 
Why bother with trying to emulate a click given you know the URL?

Why not simply do:

Code:
window.location.href = sURL;

?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
thank you BillyRayPreachersSon (Dan) for hitting me over the head with the obvious! your help is MUCH appreciated...this worked! Thank You.
 
in safari, when i do the following:

window.location.href = sURL;

where sURL can be "mailto: or "callto:8009997474".

safari main window address bar shoes a dark gray "Loading...x" and then a light gray "Loading...x" forever after the above script is run. I've seen reference to other sites to do this:

window.location.href = '#h_value6';

which seems to clear the first "Loading...x" , but once the email pops open or the telephony window pops open, another "Loading...x" reappears and remains.

Any suggetions to get rid of this ?
 
i did find a solution.

window.location.href = sURL;
window.location.href = "#";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top