htm file doesn't loaded with query string

社会主义新天地 提交于 2019-12-12 04:06:33

问题


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.


回答1:


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...




回答2:


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>


来源:https://stackoverflow.com/questions/30316914/htm-file-doesnt-loaded-with-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!