Monday, March 26, 2012

Willing to bet money that you cant figure this out!

I am working on this app... I have an iframe (hidden) in the app, and an image (also hidden) that eventually gets put into the iframe for printing.

My javascript is thus...

var img = "ctl00_ContentPlaceHolder1_cpnImage";
var daframe = document.getElementById("cpnframe");

document.getElementById("cpnframe").width = document.getElementById(img).width + "px";
document.getElementById("cpnframe").height = document.getElementById(img).height + "px";

frames[daframe].location.href = document.getElementById(img).src;
frames[daframe].focus();
setTimeout('frames[daframe].print()',10);

Now, when I run this on a regular HTML page, it works fine...

In my asp.net page, I get javascript errors stating that frames.cpnframe has no properties.

What gives?

What does the iframe look like in the HTML code generated by the ASP page compared to the HTML code in the regular HTML page where it works?


I believe it's in how you are referencing the frames. This article explains how to access frames properly.

http://www.quirksmode.org/js/frameintro.html


The iframe is the same either way. It not server side. I have looked at the page source on both and they are identical...

Very strange!

No comments:

Post a Comment