Reputation: 23
I keep on getting "Uncaught TypeError: Cannot set property of null" whenever my code hits the js code below to open a popup when clicked on a label on aspx page. Please help.
function openWindow(which) {
//alert(which);
//alert(document.getElementById('iframeClass').src);
document.getElementById('iframeClass').src = 'ViewIovationResults.aspx?ordernumber=' + which;
//alert(document.getElementById('iframeClass').src);
if (divMap.style["display"] == "none") {
divMap.style["display"] = "";
}
}
<tr>
<td width="190"><STRONG>Order Number :</STRONG></td> <td width="200"> <a onclick="javascript:openWindow('<%# DataBinder.Eval(Container.DataItem, "Order Number") %>')"><%# DataBinder.Eval(Container.DataItem, "Order Number") %></a> </td>
</tr>
Upvotes: 1
Views: 14029
Reputation: 28837
You should have inside the function var divMap = document.getElementById('divMap ');
before calling it. Unless its defined already outside the function and within scope.
Upvotes: 1
Reputation: 34846
My guess is that you do not have an element on your page with an ID value of iframeClass
. Verify the name of this element or there is no variable named divMap
.
Upvotes: 0
Reputation: 68400
Without more information is hard to say, but if that's the problematic code then, by the time that script is executed, there is no element with id iframeClass
or/and divMap
is null.
So In short:
iframeClass
?divMap
?Upvotes: 1