Click to See Complete Forum and Search --> : Master pages, content pages and Javascript


Broodmdh
June 20th, 2008, 08:41 PM
I've got an application that uses master pages and content pages. I'm using a javascript function defined in the master page to launch a modal popup window. In the onLoad of the popup, I want to grab the contents of a div defined in the parent (in the content page portion) and display it in a div on the popup. I'm using the following code but it isn't working. Any suggestions?

var varHTML = parent.document.getElementByID("ReportDiv").InnerHTML;
document.getElementByID("PrintDiv").innerHTML = varHTML;

The problem seems to be that I am unable to find "ReportDiv" in the parent. I am using a simple div, but I've also tried adding runat="server" to the div and getting the clientID without success. I imagine that the problem lies with getting the element in a content page, but I don't know what to do about it. Any help would be appreciated.

hspc
June 21st, 2008, 05:35 AM
JavaScript is case sensitive . use getElementById and innerHTML .
You can also view the HTML source of the page to check the id of the div.

Broodmdh
June 21st, 2008, 06:21 AM
I've corrected the case mistake, but that wasn't the issue. Also, I'm not using the runat="server" tag with the div so the id isn't changing (I have tried it with the tag and using the client id, and the popup still can't see it). Might this have something to do with the div being in a content page? I'm using window.open to launch the popup, and this javascript is defined in the master page and launched in the content page.

hspc
June 21st, 2008, 07:42 AM
This is not related to the mater page and content page, at the end, just some HTML is sent to the client.
So, can you specify the errors you get? try to alert after each call. Or use debugger statement to debug the JavaScript code.