htm file doesn't loaded with query string

2019-09-09 07:17发布

I'm trying to get a query string from htm file. But when I'm writing a "?param=1" in the end of the .htm url - the file not loaded and I don't see anything in this page - The error I get is: "Incorrect document syntax". When I'm opened this url without the query string in the end, its opened normally.

This is my htm file:

<html>
<head>
    <title>Test Url sender</title>
    <meta charset="utf-8">
</head>
<body>
    <script src="file.js" type="text/javascript"></script>
    <style type="text/css">
        body {
            font-size: 12px;
            margin: 0px 10px;
        }
    </style>
    <script type="text/javascript">
        window.onload = getQueryString();

        function getQueryString() {
var queryString = window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape("param").replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1");
            SendUrlsToServer(queryString);
        }

    </script>
        <p>
            test paragraph
        </p>
    </body>
    </html>

(The function SendUrlsToServer its from another js file). I need to get a query string in this url.. This htm file is web resource in crm. Any help how can I solve this? Thanks.

2条回答
贼婆χ
2楼-- · 2019-09-09 07:37

In CRM, a webpage (HTML) or Silverlight web resource page can only accept a single custom parameter called data. anything else will cause problem.

Read More...

查看更多
小情绪 Triste *
3楼-- · 2019-09-09 07:37

You are looking for "urls" in the parameter but sending "param" instead !

Change escape("urls") to escape("param") if you will be sending "param"

Try below code snippet

<html>
<head>
<title>Test Url sender</title>
<meta charset="utf-8">
</head>
<body>
<style type="text/css">
body {
    font-size: 12px;
    margin: 0px 10px;
}
</style>
<script type="text/javascript">
window.onload = getQueryString();

function getQueryString() {
var queryString = window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape("params").replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1");
SendUrlsToServer(queryString);
}
function SendUrlsToServer(x)
{
if(x.length > 0)
   alert(x);
}
</script>
<p>
    test paragraph
</p>
</body>
</html>
查看更多
登录 后发表回答