Why app.location is added instead of replacing URL in ie

I get the wrong URLs in i.e., but not in Firefox and Chrome.

Essentially, I have a text box called text-search. I use jQuery and rewriterule in htaccess to internally redirect pages. I am on a local host and all the files are in a folder called test.

In Firefox and Chrome, if you type "hello", press "enter", "hi", press "enter" and "goodbye", press "enter" in the text search box, and you will get the correct URLs:

local / test / testing / hi

as well as

local / test / testing / hi

as well as

local / test / testing / goodbye

repectively.

That is, you get

local / test / testing / hi

as well as

local / test / testing / testing / hi

as well as

local / test / testing / testing / testing / goodbye

respectively

, "" . .. .

HTML JQuery

<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]

.

+5
3

window.location , - Location.

, :

var href = window.location.href;
window.location = href.replace(/testing\/.*$/, "testing/"+$('#text-search').val());

:

var href = "" + window.location;

.

+10

: window.location.href = '/yourpage'

URL. // /

: window.location.href = '//yourpage'

+8

currenturl url bar www.theunusualcards.com/marketing.

**window.location = 'dummy-string'**

second **window.location = '/another-dummy-string'**

then in the first case it will be added to the URL in the future, and in the second case it will replace the path (i.e. / marketing) in the URL.

0
source

All Articles