Javascript: open & close new window on image's onMouseOver & onMouseOut, but only if new window onMouseOver = true?

I would recommend against using a new browser window for this task. Try something like this.

I would recommend against using a new browser window for this task. Try something like this: var popup = { open = function () { if (this. Element == null) { // create new div element to be our popup and store it in the popup object this.

Element = document. CreateElement('div'); this.element. Id = "myPopup"; // you don't need a full html document here.

Just the stuff you were putting in the tag before this.element. InnerHTML = "html"; // Some bare minimum styles to make this work as a popup. Would be better in a stylesheet this.element.

Style = "position: absolute; top: 50px; right: 50px; width: 300px; height: 300px; background-color: #fff;"; } // Add it to your tag document.body. AppendChild(this. Element); // call whatever setup functions you were calling before popUpDetails(); }, close = function () { // get rid of the popup document.body.

RemoveChild(this. Element); // any other code you want } }; // The element you want to trigger the popup var hoverOverMe = document. GetElementById("hoverOverMe"); // set our popup open and close methods to the proper events hoverOverMe.

Onmouseover = popup. Open; hoverOverMe. Onmouseout = popup.

Close; That should do it. It's much easier to control than a new browser window. You will want to tweak the CSS yourself.

EDIT: Here are instructions to do this with an actual window. To reiterate, using an actual window is not the best way to accomplish this task. A stylized div tag to look like a window is better because it offers more control, as well as standardized functionality across browsers.

However, if you must use a window, here it is: // You can use many principles from the example above, but I'll give the quick version var popup; var hoverOverMe = document. GetElementById("hoverOverMe"); hoverOverMe. Onmouseover = function () { popup = window.

Open("path_to_content", "popup"); }; hoverOverMe. Onmouseout = function () { popup.close(); }; It works, but not very well (IMHO). If the user has their settings such that new windows open in new tabs (as I do), then a tab will open up.

Javascript has no control over that. In Firefox, the new tab will open and gain focus, at which point it immediately closes because hoverOverMe had its onmouseout event fired (which obviously closes the window). I imagine you'd have this same problem with an actual window, too.

Thank you for your suggestion. I had something similar to your code before, but I really want a pop-up window for my movie database. I was trying to make something similar to the Netflix popup window when you hover over a movie picture.

Thanks again for trying to help. – user848353 Jul 22 at 2:49 Edited the answer to include a way to do this with a window. FYI, Netflix does not use actual windows for what you are talking about.

They use a div, like my original answer (you can check on that by inspecting the element in Firefox or Chome). Whatever you do, I hope this helps ;) – benekastah Jul 22 at 4:25 Thanks again for helping a newbie like me – user848353 Jul 22 at 15:53 Everyone's a newbie at something :) No problem. – benekastah Jul 23 at 5:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions