0
<script language="javascript">
function frompost()
{
  var string=$('#indexsearch').val();
  var url=string.split('=');
  if(url==""){
  var url=string.split('video/');  
  }
  var finalurl='http://watchvideos.tv/watch/'+url[1];
  window.location = finalurl;
  //$('#srchFrm').attr('action',finalurl);
  //document.srchFrm.submit();
}
</script>

I have a problem with this script - it's Ok as long as indexsearch field contains = and fails when it's supposed to work as well - with video/ in the field

1 Answer 1

1

Try it like this:

function frompost()
{
  var str = $('#indexsearch').val(),
      url = str.split(/=|video\//),
      finalurl = 'http://watchvideos.tv/watch/'+url[1];
  window.location = finalurl;
}
Sign up to request clarification or add additional context in comments.

3 Comments

url[1] is passed as undefined instead of the value after video/
What's the value of $('#indexsearch').val()?
Well http://videobb.com/video/PFt6bfmNMSlW'.split(/=|video\//) returns ["http://videobb.com/", "PFt6bfmNMSlW"] here, so I'm not sure why url[1] shouldn't exist. Could video/... be in uppercase? Than use .split(/=|video\//i)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.