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?

7
  • 3
    Have you checked the javascript console errors? Commented Feb 9, 2015 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
    Commented Feb 9, 2015 at 15:40
  • Thanks! Just checked it says ReferenceError: awin is not defined.
    – MnZ
    Commented Feb 9, 2015 at 15:40
  • @BarCotter On trying onmouseout="alert(awin);" nothing happens the iframe remains open
    – MnZ
    Commented Feb 9, 2015 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
    Commented Feb 9, 2015 at 15:49

2 Answers 2

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}

</apex:outputLink>

Thanks!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .