I am getting wrong URLs in ie but not in firefox and chrome.
Basically, I have a textfield called text-search. I am using jQuery and rewriterule in htaccess to internally redirect pages. I am on localhost and all files are in a folder called test.
In firefox and chrome, if you enter 'hello' hit enter, 'hi' hit enter and 'goodbye' hit enter in the text-search box you get the correct URLs as
localhost/test/testing/hello
and
localhost/test/testing/hi
and
localhost/test/testing/goodbye
repectively.
In ie you get
localhost/test/testing/hello
and
localhost/test/testing/testing/hi
and
localhost/test/testing/testing/testing/goodbye
respectively
The problem here is that 'testing' is prepending. How to stop this from happening in ie. I could not find an answer to this problem on the web.
html and jquery code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<base href="http://localhost/test/" />
<script src="jQuery.js"></script>
<script>
$(document).ready(function(){
$("#text-search").keyup(function(e){
if (e.keyCode == 13){
window.location.replace("testing/"+$('#text-search').val());
}
})
})
</script>
</head>
<body>
<input type='text' id='text-search'>
</body>
</html>
.htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^testing/(.+)$ /test/testing.php?string=$1 [L]
Can you please help me on this. Many thanks
Window location. The replace() method replaces the current document with a new one.
The Location. assign() method causes the window to load and display the document at the URL specified. After the navigation occurs, the user can navigate back to the page that called Location.
Answer: Use the window. location. href Property location. href property to get the entire URL of the current page which includes host name, query string, fragment identifier, etc.
Window Location Href The window.location.href property returns the URL of the current page.
If you set like this: window.location.href = '/yourpage'
it will append the url. To avoid that use //
instead of /
so it will look like :window.location.href = '//yourpage'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With