admin管理员组文章数量:1290338
The following piece of code is working on Android devices and iPhone simulator but not working on the iPhone device.
<a style="color:#1cffff" href="#" onclick="window.open('.');"><u>mysite_name</u></a>
I have tried the following:
<a style="color:#1cffff" href="">mysite_name</a>
But none of them have worked. Please advise.
The following piece of code is working on Android devices and iPhone simulator but not working on the iPhone device.
<a style="color:#1cffff" href="#" onclick="window.open('http://somesite..');"><u>mysite_name</u></a>
I have tried the following:
<a style="color:#1cffff" href="http://somesite.">mysite_name</a>
But none of them have worked. Please advise.
Share Improve this question edited Oct 7, 2019 at 6:48 Rohit416 3,4963 gold badges26 silver badges42 bronze badges asked Feb 24, 2012 at 7:46 DrayDray 1,9545 gold badges27 silver badges42 bronze badges 11- 2 How exactly is the second example not working? What happens or doesn't happen? – Pekka Commented Feb 24, 2012 at 7:47
- its not working.i am able to click the link. its not redirecting to my page.the same code working good in android phones, and all browsers... – Dray Commented Feb 24, 2012 at 7:51
- 2 Post some more code. It's not working because you have some kind of prevented event bubbling. – Andreas Louv Commented Feb 24, 2012 at 9:30
- just I am displaying the link inside a div. its very simple. not much code involved. Code is working fine fo all browsers and phones except iPhone. is there any other way for redirecting the user to mywebsite when they click on the link?? – Dray Commented Feb 24, 2012 at 9:47
- 1 What you posted is perfectly valid HTML (even though a bad practice). You really should let us see your Javascript code. If the code is working fine everywhere except iPhone, then obviously iPhone's problem must be the Javascript code of yours. – Petr Vostrel Commented Mar 22, 2012 at 12:43
5 Answers
Reset to default 1 +50Do you have an HTML <base>
tag in your document? Something like this:
<base href="http://somesite." target="_blank">
If so, all of your links will open in a separate window by default. You'll probably need to get rid of that element or explicitly set a target on links that you want to open in the same window:
<a href="http://somesite." target="_self">Link text</a>
Here are some more details on the <base>
element.
try this if you use webview
NSString *str =@"<a style='color:#1cffff' href='http://www.somesite.'>www.somesite.</a>",
[webview loadHTMLString:[NSString stringWithFormat:@"<html><body style='background-color: transparent;font-family:Helvetica;font-size:13;color: rgb(65,75,86);'>%@</body></html>",str ] baseURL:nil];
not then use
<a href="javascript:yourFunction()">Some Link</a>
You can use something like this as an alternative solution
<a href=”javascript:window.location.href=’http://google.de’”>Link</a>
This has also a benefit in fullscreen webapps that you added to homescreen since it won't kick you out of the app, into safari but will load the href into the current webview.
Please try this:
<a style="color:#1cffff" href="http://somesite." target="_self">mysite_name</a>
I do not know as you told you have tried everything there.
Okay so let me give you some hint regarding debugging tips.
I hope it may help you out. Just build the app for iPhone device and go to that build folder and open the app (show package and contents) and open your html file in safari and use the debug/development tool of safari browser or you may try in other brwoser for to just debug.
本文标签: androidjavascript href link not working in iPhoneStack Overflow
版权声明:本文标题:android - javascript: href link not working in iPhone - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741498283a2381935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论