Location. href and location. Search

Source: Internet
Author: User

1.doc ument. Location. href returns the complete URL. Such as: http://www.cftea.com/foo.asp? P = 1

Reference location. Search is from the current URL? String starting
Such as: http://www.51js.com/viewthread.php? Tid = 22720
What is its search? Tid = 22720

With this function, you can easily obtain the parameters following the connection. This function allows the user's parent window to pass parameters to the Child Window.
Eg: Java code

  1. Function OpenTable (ID ){
  2. VaR feathers = "status = No, width = pixel PX, Height = 670px, Top = 0px, menubar = No, resizable = No, scrollbars = Yes, toolbar = No, channelmode = No ";
  3. VaR openwin = Window. Open ("allinfo.html? "+ ID +", "+ new date (). gettime ()," declare ", feathers );
  4. Openwin. Focus ();
  5. }
function openTable(id){var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar=no,channelmode=no";var openWin = window.open("allInfo.html?"+id+","+new Date().getTime(),"declare",feathers);openWin.focus();}

On the allinfo.html page, if we want to obtain the id value, we can obtain the Java code in this way.

  1. <SCRIPT type = "text/JavaScript">
  2. VaR Params = Window. Location. Search; // Params :? ID, date
  3. VaR arr = Params. substring (1). Split (",");
  4. VaR id = arr [0];
  5. </SCRIPT>
<script type="text/javascript">var params= window.location.search;//params:?id,datevar arr = params.substring(1).split(",");var id = arr[0];</script>

2.doc ument. Location. search returns the querystring part of the URL, including "?". For example :? P = 1

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.