How to use search property in Location object from Javascript

Description

The search property can be set with new values that alter the current URL.

assume starting at http://www.java2s.com/index.htm

location.search = "?q=javascript";

Example

changes URL to "http://www.java2s.com/index.htm?q=javascript"


<!DOCTYPE HTML> 
<html> 
    <body> 
        <script> 
                location.search = "?q=javascript"; 
        </script> 
    </body> 
</html><!--   www .j  a v a  2  s  .c  o  m-->

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window