Search This Blog

Thursday, March 21, 2019

SharePoint Page viewer Web Part instead of using iframe with dynamic URL


Page viewer web part instead of iframe

Step1: Create test SharePoint Page and Go and click edit  
Step2 : Add Script editor webpart and insert below script

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">
      
        function getQueryStringRegExp(name) {
            var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
            if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " "));
            return "";
        }

        var listId = "8EF5E89F-FC59-467F-9C69-89AD71007565";
        var qryId = getQueryStringRegExp('ReqID');
        if (qryId != "") {        
            document.write("<iframe src='http://sp2016:8080/_layouts/15/Versions.aspx?list=" + listId + "&ID=" + qryId + "' width=100% height=100%></iframe>");
        }

    </script>
</head>
<body>

</body>
</html>

No comments:

Post a Comment