Home>

Customizing the search program that can process the display HTML.
Specifically, the HTML for displaying the file search program Everything is customized.

Everything
http://www.voidtools.com/support/everything/
Japanese help
https://sites.google.com/site/everythingjphelp/http

Since it is a type that sends a GET request to itself, the selection status of the form can be determined from the URL.
So I got the URL with JavaScrypt, decided to reflect it in the HTML form
Works with Chrome and Firefox, but not with Internet Explorer 11. . .

How can I get it to work in IE ...?

Thank you.

Error message

There is no error message.
However, the selection position of the check box and select box returns to the default
The selection at the last search is not reflected. . .

Applicable source code
<! DOCTYPE HTML PUBLIC "-// W3C // DTD HTML 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose .dtd ">
<head>
<meta http-equiv = "Content-Type" content = "text/html;charset = utf-8">
<meta name = "viewport" content = "width = 512">
<title>Files Search</title>
<link rel = "stylesheet" href = "/ ress.css" type = "text/css">
<link rel = "stylesheet" href = "/ main.css" type = "text/css">
<link rel = "shortcut icon" href = "/ favicon.ico" type = "image/x-icon">
<script src = "/ jquery.min.js" type = "text/javascript">
</script>
<script src = "/ scripts.js" type = "text/javascript">
</script>
</head>
<body>

~ Explanation ~

<center>
  <div>
    <form name = "sf" action = "/" method = "get">
      <input name = "search" type = "text" title = "Search Everything" value = "">
      <input type = "submit" value = "search" />
      <br>
      <input type = "checkbox" name = "path" value = "1" checked = "checked">
      <select name = "count">
        <option value = "30">30</option>
        <option value = "50">50</option>
        <option value = "100">100 cases</option>
        <option value = "500">500 cases</option>
      </select>
      <br>
    </form>
  </div>

~ Search result display ~

</center>
</body>
// ----------------------------------- -----------------------------------
// scripts.js
// Rebuilt for IE
// ------------------------------------------------ ----------------------
// ◆ Definition// 2. Get parameters from URL and reflect in HTML
var params = (new URL (document.location)). searchParams;
var path = Boolean (params.get ("path"));
var count = parseInt (params.get ("count"));
var paramOld = location.search;
// ------------------------------------------------ ----------------------
// ◆ Conducted when reading
$(function () {
// 2. Get parameters and reflect in HTML
  // Old browser completion
  if (! path) {
    paramOld = paramOld.substring (1);
    / * "&Amp;" splits the argument into an array * /
    var pair = paramOld.split ("&");
    var i = temp = "";
    var key = new Array ();
    for (i = 0;i<pair.length;i ++) {
      / * Divide array value by "=" * /
      temp = pair [i] .split ("=");
      keyName = temp [0];
      keyValue = temp [1];
      / * Create an associative array of keys and values ​​* /
      key [keyName] = keyValue;
    }
    var path = count = "";
    path = Boolean (key ["path"]);
    count = parseInt (key ["count"]);
  }
  // Return check box selection
  document.sf.path.checked = !! (path);
  // Select box selection return
  document.sf.count.value = count;
});
// ----------------------------------- -----------------------------------
// scripts.js
// What worked for Chrome
// ------------------------------------------------ ----------------------
// ◆ Definition
// 2. Get parameters from URL and reflect in HTML
var params = (new URL (document.location)). searchParams;
var path = Boolean (params.get ("path"));
var count = parseInt (params.get ("count"));
// ------------------------------------------------ ----------------------
// ◆ Conducted when reading
$(function () {
// 2. Get parameters and reflect in HTML
  // Return check box selection
  document.sf.path.checked = !! (path);
  // Select box selection return
  document.sf.count.value = count;
});
Tried

I found information that URL.searchParams didn't work
Added URL acquisition processing at location.search.
◆ Even if you comment out the top three lines of the definition part, it will work in Chrome, so
I thought it was going well ...

Supplemental information (FW/tool version etc.)

Because the specification of the original program does not set up an HTML server
PHP and others are difficult to build.
Thank you in HTML + JavaScript.

  • Answer # 1

    Is there an error in the browser development tool console? ?

    javascript is executed from the top in the order in which it was written.
    (The code that is executed later is also read in the order in which it is written.)

    And if it stops with an error, it will not be executed after that.
    (The code to be executed later is not loaded.)

    URL () doesn't seem to be supported in IE, so

    script.js

    var params = (new URL (document.location)). searchParams;


    When is executed, a fatal error will occur, and the js process should end here.

    It is written behind it

    if (! path) {


    You haven't reached this judgment part.

    Because you must avoid fatal errors,

    For example,

    var now_location = document.location;
    var path = null, count = null;
    $(function () {
      // Check if URL () can be used
      if (typeof URL == 'function') {
        // Write a process that can use URL ()
        var params = (new URL (now_location)). searchParams;
        path = Boolean (params.get ("path"));
        count = parseInt (params.get ("count"));
      } else {
        // Because URL () cannot be used, write a process to get from search string
        var paramOld = now_location.search.substring (1);
        // ・ ・ ・ Omitted
      }
      // Return check box selection
      document.sf.path.checked = !! (path);
      // Select box selection return
      document.sf.count.value = count;
    });
    I think a judgment like

    is necessary.

    * Since we have not verified the operation of the reference code, please forgive us if you have any spelling mistakes or bugs. ^^;

  • Answer # 2

    This is the source code that worked.

    // ----------------------------------- -----------------------------------
    // scrypts.js
    // JavaScrypt that worked
    // ------------------------------------------------ ----------------------
    // ◆ Definition
    // 2. Get parameters from URL and reflect in HTML
    var now_location = document.location;
    var path = null, count = null;
    // ------------------------------------------------ ----------------------
    // ◆ Conducted when reading
    $(function () {
    // 2. Get parameters and reflect in HTML
      // Check if URL () can be used
      if (typeof URL == 'function') {
        // URL () can be used
        var params = (new URL (now_location)). searchParams;
        path = Boolean (params.get ("path"));
        count = parseInt (params.get ("count"));
      } else {
        // URL () cannot be used, so get from search string
        // IE assumed processing
        var paramOld = now_location.search.substring (1);
        // Divide the argument with&into an array
        var pair = paramOld.split ("&");
        var i = temp = "";
        var key = new Array ();
        for (i = 0;i<pair.length;i ++) {
          // Divide array value by "="
          temp = pair [i] .split ("=");
          keyName = temp [0];
          keyValue = temp [1];
          // create an associative array of keys and values
          key [keyName] = keyValue;
        } // _for
        var path = count = "";
        path = Boolean (key ["path"]);
        count = parseInt (key ["count"]);
      } // _if_else
      // Return check box selection
      document.sf.path.checked = !! (path);
      // Select box selection return
      document.sf.count.value = count;
    });

Related articles