0

I got a html-file in some folder. The file is called "file.html". I create a link-file to "file.html" on my desktop or anywhere else. The link file's name is e.g. "Monday".

For my "file.html" I am using some JavaScript to filter some rows of a table which is being created.

My question is: Is it possible to read "Monday" of my link file, open the original file and set "Monday" as the selected entry of my already existing drop-down-menu? If so, how can I do this?

My xslt file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<html>
    <head><title>Shared Secrets</title></head>

<body onload="JavaScript_Filter();">
    <h1>Dokumentation Shared Secrets durch RD/UEA</h1>

        <img style="position: absolute; top:80px; left:920px;" src="../logo/logo.jpg" alt="Logo RD/U"></img>

    <table id="myTable">
        <colgroup>
            <col width="150" style="background-color:e2e2e2"></col>         
        </colgroup>
        <tr  style ="background-color:a5a5a5">
            <th rowspan="2">plane
                <select id="modelRangeDropdown" onclick="JavaScript_Filter()">
                     <option selected="selected">All</option>
                     <xsl:for-each select="logstore/plane">
                        <option>
                         <xsl:value-of select="Name" />
                        </option>
                     </xsl:for-each>                    
                </select>                   
            </th>   
            <th colspan="2" width="330">date</th>
            <th rowspan="2">Secret
                <input type="checkbox" id="identicalSecrets" onclick="JavaScript_Filter()"></input>
                <label for="identicalSecrets">Hide identical secrets</label>
            </th>
        </tr>

        <tr>
            <th align="center" style="background-color:a5a5a5">begin</th>
            <th align="center" style="background-color:a5a5a5">end</th>
        </tr>
        <xsl:for-each select="logstore/plane/trigger">
            <tr>
                <td align="center"><xsl:value-of select="../Name"/></td>
                <td align="center"><xsl:value-of select="date"/></td>
                <td align="center"><xsl:value-of select="date"/></td>
                <td><xsl:value-of select="secret"/></td>
            </tr>
        </xsl:for-each>
    </table>    
    <script type="text/javascript" src="JavaScript_Filter.js"></script>     
</body>
</html>
</xsl:template>
</xsl:stylesheet>

My JavaScript Code:

// Just contains some filtering code... does not matter for my question
2
  • You have to add some code of what you already have. Commented Jun 18, 2019 at 11:10
  • Okay I just like to know if I can read "Monday" of my link-file. I do not know how my code should help you... but I have edited it. Commented Jun 18, 2019 at 11:20

2 Answers 2

1

Links (at least in Windows) are file-system pointers, when clicked the referred resource is opened by the OS in reference to the mime-type of the underlying resource. So no, there is no data passed from the link to the resource itself as this is handled by the OS internally.

My first idea would be to have one HTML page named "Monday.htm" that simply forwards to your target HTML page and then check its referrer. This does not work with local files, though:

A Referer header is not sent by browsers if:

  • The referring resource is a local "file" or "data" URI.
  • An unsecured HTTP request is used and the referring page was received with a secure protocol (HTTPS).

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer

The second option would be to add your identifier to the URL of the requested resource and then use this for identification. Your shortcut page would have the following contents:

<html>
  <head>
    <meta http-equiv="Refresh" content="0;url=test.htm#Monday"/>
  </head>
</html>

The word following the hash symbol #will be our identifier.

In your "main application" now just check for the parameter:

<html>
  <body>
    <script>
      var id = document.location.hash.substring(1);
      alert(id);
    </script>
  </body>
</html>

Don't know if this could be an option for you.

Sign up to request clarification or add additional context in comments.

Comments

0

I have also find a solution which worked for me. I have created a shortcut to internet_explorer.exe clicked on property and changed the destination path to "C:.../iexplore.exe" "file://path_to_html?parameter".

Now it is possible to read my URL and save a substring (my parameter) to "parameterModelrange":

var currentLocation = window.location.href;
var parameterModelrange = currentLocation.substring(36);

And then I can go through my Drop-Down-Menu and compare each entry with my parameter and select my desired parameter if I have found the entry in my Drop-Down-Menu:

var mySelectNode = document.getElementById("modelRangeDropdown"); 
var l = mySelectNode.options.length;
for (var i = 0; i < l; i++) { 
    var opt = mySelectNode[i];

    if (opt.text === parameterModelrange) { 
       document.getElementById("modelRangeDropdown").selectedIndex = i;
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.