0

I have a webpart page with multiple parts, two of these are page viewer web parts.

I would like to be able to change the page displayed in one of them based on input from a form in the other. i.e. enter a url in the box, press go and it updates the url of the other page viewer and refreshes the content.

Is something like this possible, and is there a relatively easy way to accomplish it?

Thanks in advance.

KB

  • May be you should reframe your question for making others better understand!! – Amit Apr 16 '14 at 13:37
1

This answer may be specific for SharePoint 2010: Using javascript (even better with jQuery) you can accomplish this.

On the webpart page, your page viewer part will contain a div element with a unique id (e.g. WebPartWPQ3). Inside this div is an iframe that points to the page to display (i.e. src="your page"). You can use your favorite DOM inspector to find this div and get the id.

Using javascript/jQuery, you could reference the div with that unique id for your web part, grab the iframe, and then change the src attribute to point to your new page.

Untested snippet:

<script type="text/javascript" src="http://sp2010/_layouts/smit/jquery-1.8.3.min.js"></script>
<script type="text/javascript">

function ChangeUrl(newurl)
{
   var pg = $("#WebPartWPQ3 iframe");
   pg.attr('src',newurl);
}

Have another bit of javascript/jQuery that responds to your URL textbox change event that calls the above function (passing in the value for the new URL from the textbox as the newurl parameter).

Forgive me for not testing the above snippet (my SharePoint box is out of commision at the moment). But the jist of the above should work.

  • Thanks for that, this puts me on the right road, should be able to take that and run with it. – brand2k Apr 16 '14 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.