Anybody have a script to detect the existence of a url?

  • 1
  • Question
  • Updated 7 years ago
Does anybody know of a cross browser compatible script which detects if a url exists? I've searched google and i could not find anything that actually works for me.
Thanks in advance!
Photo of Kevin

Kevin

  • 475 Posts
  • 29 Reply Likes
  • happy

Posted 7 years ago

  • 1
Photo of Laura Thomas

Laura Thomas, Social Media Coordinator

  • 4536 Posts
  • 211 Reply Likes
Hi Kevin,

Can you please explain a bit more about the purpose of the script? If we have a better understanding of what you are trying to accomplish we may be able to offer suggestions but I'm not sure I understand what you are looking for.
Photo of Kevin

Kevin

  • 475 Posts
  • 29 Reply Likes
My site, www.campatet.com, has this browser function. When you type, it searches, when you press enter/return or go, it goes to the page that is specified in the textbox. But what if the url is not valid/doesn't exist? The loading sign will just keep turning and turning. The page is displayed in an iframe. All I want to do is validate the url before the frame display's it. Once I can do that, if the url is not valid, I can make the site search it instead.
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Thanks for explaining Kevin! While I do not know of a way to do this, hopefully someone on this forum will be able to point you in the right direction!
Photo of SilverX

SilverX

  • 492 Posts
  • 40 Reply Likes
That can be done with php code.
Please check how it's running in my site
http://texby.com/[search keyword here]

if the requested page doesn't exist, you will get a search box with keywords filled in.

Since yola doesn't allow php, go to GWMT help and search for "soft 404". Google has a tool for that. Just an HTML code. That code simply detects if page header is 404. If yes, the {request_uri} header sends to Google and brings search results.
Photo of Amar

Amar

  • 201 Posts
  • 14 Reply Likes
Is your site still with Yola? It doesn't look like it. Where is it hosted now?

Amar
Photo of Kevin

Kevin

  • 475 Posts
  • 29 Reply Likes
Thanks for the reply, but the thing is, the contect i'm dealing with is in a frame. Anyways, i've decided so that everytime it redirects, it'll use the google i'm feeling lucky function, so if the url is wrong, it will likely fix it.