URL重定向基于输入,但如果输入URL不存在,则不重定向无法使PHP工作
URL Redirect based on input but if input url does not exist do not redirect cant get PHP to work
@themask你好,谢谢你的帮助,我已经打开了php,现在只有这个代码
<script>
document.forms[0].onsubmit =
function() {
var to = document.getElementById('myInput').value;
var ajax = new XMLHttpRequest;
ajax.onreadystate = function() {
if(this.readyState == 4 && this.status != 404) {
window.locaiton.replace(to);
} else {
window.location.replace('http://www.mysite.com/incontinence/protective_underwear/presto_protective_underwear/');
}
};
ajax.open('GET',to);
ajax.send(null);
};
</script>
<form onsubmit="location.href='http://www.mysite.com/coupons/' + document.getElementById('myInput').value; return false;" >
<input type="text" id="myInput" />
<input name="Submit" type="submit" id="Submit" />
</form>
但如果使用了错误的代码,它仍然会将我发送到不正确的URL。这就像是一起跳过java。
任何额外的帮助都将是伟大的。
谢谢,云母
谢谢,云母
尝试使用get_headers((
$headers = get_headers('http://www.activelifemed.com/incontinence/protective_underwear/presto_protective_underwear/')
if($headers[0] == 'HTTP/1.1 200 OK'){
//exists
}
else{
//doesn't exist
}
http://www.php.net/manual/en/function.get-headers.php
您可以使用JavaScript:
document.forms[0].onsubmit =
function() {
var to = document.getElementById('myInput').value;
var ajax = new XMLHttpRequest;
ajax.onreadystate = function() {
if(this.readyState == 4 && this.status != 404) {
window.locaiton.replace(to);
} else {
window.location.replace('http://www.mysite.com/incontinence/protective_underwear/presto_protective_underwear/');
}
};
ajax.open('GET',to);
ajax.send(null);
};
相关文章:
- 需要URL模板占位符查找和替换功能的输入
- 如何存储&读取输入字段中的任意url
- 替换“;var url”;使用文本框输入
- 在Jquery中将鼠标悬停在图像上后获取输入标记的URL
- 如果输入val=,请转到URL
- 如果未输入URL,则隐藏按钮
- 将输入id传递到jquery ui自动完成中的url
- 验证多个URL输入字段
- 表单输入和选择值将创建一个URL
- I'm试图创建一个html表单,根据字段的输入生成url地址
- 如何从输入到url的路径创建html文件
- Regex来验证texarea输入,该输入必须是用新行分隔的URL
- Chrome webRequest只侦听用户输入的URL
- 如何识别用户在评论框中输入的URL
- 提交的表单重定向到输入URL
- 如何检查“http://”是否包含在 Angular .js 应用程序的 url 输入中
- Javascript或JQuery,用于在URL输入文本框时显示图像
- HTML5 URL输入元素的URL模式或REGEX
- 为从特定URL输入的用户更改页面元素
- 根据URL输入动态更改文本