Reputation: 1
See it live: http://umiss.lib.olemiss.edu/screens/urlconverter.html The form works in Firefox but not in Chrome or IE. In Firefox, you input a URL and the new proxied URL is displayed. It converts old proxied URLs as well to the new format. In Chrome and IE, the convert button results in nothing displayed. Any suggestions?
<script type="text/javascript">
function displayProxyUrl() {
url = document.getElementById('url').value;
document.getElementById('proxyurl').value = checkUrl(url);
}
function checkUrl (url){
if (url.contains ("http://0")>-1){
return "http://umiss.idm.oclc.org/login?url=" + url.replace("0-","").replace(".umiss.lib.olemiss.edu","");
}
else
return "http://umiss.idm.oclc.org/login?url=" + url;
}
</script>
</p>
<form action="javascript:void(0)" onsubmit="gotoProxyUrl(); return false;">
<p align="center"><strong>URL Converter </strong></p>
<p align="center">This form will convert both current proxied URLs (starting 0-) and base URLS (http://www.jstor.org). </p>
<p>URL:
<input type="url" name="url" id="url" size="100" />
<p>
<input type="button" value="Convert to Proxy URL " style="width: 10em;" onclick="displayProxyUrl()" />
<p>New Proxy URL:
<input type="text" name="proxyurl" id="proxyurl" size="100" onfocus="this.select()" readonly="readonly" />
<p>
<p>NOTE: If the URL ends in .pl (http://www.olemiss.edu/cgi-bin/library/aph.pl), don't convert it; they remain the same.
</form>
Upvotes: 0
Views: 60
Reputation: 3754
Instead of contains
use indexOf
:
if(url.indexOf("http://0") != -1) {
//do your things
}
EDIT
.contains()
(and .includes()
) are experimental functions (part of the ECMAScript 6 proposal). They don't have cross-browser support. (e.g. do not work in Chrome)
Check this for further information
Upvotes: 1