0

I'm trying to show an iframe onmouseover event and close that iframe onmouseout. Onmouseover is working but not the onmouseout event. Here's what I have tried....

<apex:outputLink value="OrderTrackingClass?id={!o.id}" 
                 onmouseover="var awin=window.open('OrderLines?id={!o.id}','Order Lines','height=300, width=1000, left=400, scrollbars=yes');"
                 onmouseout="awin.close();">
    {!o.Orders__c}
</apex:outputLink>

What am I missing?

  • 3
    Have you checked the javascript console errors? – Sergej Utko Feb 9 '15 at 15:33
  • 1
    The onmouseover event creates the awin variable which may not be visible by the onmouseout event. Try doing something like onmouseout="alert(awin);" to see what awin is in the onmouseout event. – BarCotter Feb 9 '15 at 15:40
  • Thanks! Just checked it says ReferenceError: awin is not defined. – MnZ Feb 9 '15 at 15:40
  • @BarCotter On trying onmouseout="alert(awin);" nothing happens the iframe remains open – MnZ Feb 9 '15 at 15:44
  • It wasn't a solution to fix your issue, it was only a way of getting the awin variable displayed in the alert box which would highlight the issue that it is an unknown variable – BarCotter Feb 9 '15 at 15:49
4

I think var is creating a private variable which is unknown to the onmouseout call. Removing var making the awin variable to available in global scope. So that onmouseout it's getting awin variable and closing it.

1

It was a blind guess! I removed the keyword var and the onmouseout started working!

  <apex:outputLink value="OrderTrackingClass?id={!o.id}" 
             onmouseover="awin=window.open('OrderLines?id={!o.id}','Order Lines','height=300, width=1000, left=400, scrollbars=yes');"
             onmouseout="awin.close();">
{!o.Orders__c}

I don't understand the reason though! Please comment if anyone does. Thanks!

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.