last day (15 days later) » 

4:36 PM
0
A: JavaScript : Prevent showing alert when the url being opened is invalid

Mike CYou can't prevent Safari from presenting that alert when you attempt to access an invalid URL. Perhaps you should verify that it is a valid URL before attempting to access it.

 
how can I validate the URL, is there any way?
 
A quick search shows some simple ways.
 
the url is valid only, I just want to check the edge case, when the webpage might be down, I think regex may not help in this situation, any comments..?
 
@Krish Which one is it? Is the URL invalid, is the domain invalid (groogle.com instead of google.com), or the site is down (getting a 404 error)?
 
it includes may the URL's formats like, iPhone considers tel://1234567890 also a valid url, but lets say if the url is tele://1234567890, it is a wrong url, so how do i catch this
 
4:36 PM
Regex will catch that. You just need to adjust your regex to look for tel in addition to http and https. It's a trivial addition.
 
yes, but there can be so many such formats, so we can not include all of them in RegEx. iPhone has lot of urls for calendar, notes, mail.. etc..
 
@Krish You can include them all in a regex. Nothing is stopping you. You have to store what a valid protocol is somewhere. Other than that, you could attempt to split on :// then check if the first section matches your allowed set of protocols.
 
it is impossible to add them all as we do not know all the formats available
 
You can know what protocols you will accept. If you can't decide what is and what isn't an acceptable protocol then you cannot determine what the browser will accept.
It's impossible to "catch" an error when the browser tries to access an invalid protocol. It is possible to determine what protocols your application will allow. There are a finite number of protocols in the world that you should worry about.
 
5:00 PM
No, here is my problem
I have an application for iPHone
it registers as checkthisurl://sometext as valid url
but it is active only when my application is active..
I can only check if my application is installed on the phone why opening the url checkthisurl://
if i can open this url, my application is installed, if i can not open this url my app is not istalled
Now, if the application is installed on the phone, the webpage is opening it properly
but, when the application is not installed, the url is not valid, so it is giving the error alert
do you get the issue now?
 
5:15 PM
That makes a lot more sense. You should have specified that in the question. Then you're still stuck. Either that or you could try sending an AJAX requests to the URL and checking the response.
 
can you please help me with more info, i will check how it works.
 
 
2 hours later…
7:09 PM
AJAX is only available for http, https, ftp... etc, it is not available for any other kind of protocol
 

last day (15 days later) »