The way I found to create a dynamic page viewer based on URL parameters is the following:

You need to use the “Script Editor” web part in order to inject some simple JavaScript in the page, now copy the following code into the webpart.

<script type=”text/javascript”>
if(window.location.search.indexOf(‘permissions’) > 0){
document.write(‘<iframe src=” https://www.microsoft.com” width=”699px” height=”800px”>
</iframe> ‘)
} else {
document.write(‘<iframe src=” https://www.youtube.com” width=”699px” height=”800px”>
</iframe> ‘)
}
</script>

On this script, I am using the first part to identify if the variable “permissions” exist on the page load, if it does the code redirect the iframe content to the Microsoft URL, if it doesn’t then it will display the youtube URL.

The URL parameter in our site should looks like https://domain/site/home.aspx?permissions=1

Remember that the iframe need to have a https page call otherwise the page will not be displayed, sharepoint online is now in a secure environment. 😀

Leave a Comment

Your email address will not be published. Required fields are marked *