Window.location.href when you put it in a separate JS file.

Source: Internet
Author: User

Scenario: Assuming the address of the current browser address bar is: http://localhost:8888/SSHBoot/tourist/homeMainAction_signInUI.do,

Now I want to locate the address "http://localhost:8888/SSHBoot/member/adminMainAction_mainUI.do" When I click the button.

The following JS code is no problem, put the JS script on the page

<HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Bootstrap Learning</title></Head><Body>    <inputID= "Btnsubmit"class= "btn btn-success btn-block btn-lg"type= "button"value= "Tap">    <Scripttype= "Text/javascript"src= "${basepath}/js/homemainaction/signinui.js"CHARSET= "Utf-8"></Script>
<script type= "Text/javascript" >
$ (function ($) {
Login Click
$ ("#btnSubmit"). Click (function () {
Window.location.href = "Http://localhost:8888/SSHBoot/member/adminMainAction_mainUI.do";
});
});
</script>
</Body></HTML>

However, if I extract the above JS script to be placed in the "signinui.js" file, as follows. This approach does not achieve the desired effect:

The address in the browser address bar is: http://localhost:8888/SSHBoot/tourist/http://localhost:8888/member/index.jsp

<HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Bootstrap Learning</title></Head><Body>    <inputID= "Btnsubmit"class= "btn btn-success btn-block btn-lg"type= "button"value= "Tap">    <Scripttype= "Text/javascript"src= "${basepath}/js/homemainaction/signinui.js"CHARSET= "Utf-8"></Script>    </Body></HTML>

signinui.js:

$ (function($) {            //  Login Click            $ ("#btnSubmit"). Click (function( {                = "http://localhost:8888/SSHBoot/member/adminMainAction_mainUI.do";});        });

The following path styles should be used at this time:

$ (function($) {            //  Login Click            $ ("#btnSubmit"). Click (  function() {                = ": /member/adminmainaction_mainui.do ";            });        });

Window.location.href when you put it in a separate JS file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.