非常感謝您幫助我以前解決我的JavaScript腳本問題。我目前的問題是,我需要打開&分別關閉一個圖像的onMouseOver & onMouseOut上的新窗口,但是如果新窗口onMouseOver == true,那麼我不希望新窗口關閉。Javascript:在圖像的onMouseOver&onMouseOut上打開並關閉新窗口,但僅當新窗口onMouseOver = true時
我相信有一個簡單的解決方案,但我似乎無法找到一種方法來取消圖像的onMouseOut =「closeDetails();」如果用戶懸停在新窗口。以下是我正在處理的大部分代碼。在此先感謝您的幫助。
<body>
<img name="img1" id="img1" onMouseOver="windowDelay(this);"
onMouseOut="closeDetails();" src="images/127.jpg" height="240" width="166"/>
</body>
<script language="JavaScript" type="text/javascript">
// This opens the movie details pop-up after an
// half second interval.
function windowDelay(thatImg)
{
winOpenTimer = window.setTimeout(function() {openDetails(thatImg);}, 2000);
}
// This is the function that will open the
// new window when the mouse is moved over the image
function openDetails(thatImg)
{
// This creates a new window and uses the hovered image name as the window
// name so that it can be used in the that window's javascript
newWindow = open("", thatImg.name,"width=400,height=500,left=410,top=210");
// open new document
newWindow.document.open();
// Text of the new document
// Replace your " with ' or \" or your document.write statements will fail
newWindow.document.write("<html><head><title>Movies</title>");
newWindow.document.write("<script src='myDetails.js' type='text/javascript'>");
newWindow.document.write("</script></head>");
newWindow.document.write("<body bgcolor='white' onload='popUpDetails();'>");
newWindow.document.write("... SOME OTHER HTML....");
newWindow.document.write("</body></html>");
// close the document
newWindow.document.close();
}
// This is the function that will call the
// closeWindow() after 2 seconds
// when the mouse is moved off the image.
function closeDetails()
{
winCloseTimer = window.setTimeout("closeWindow();", 2000);
}
// This function closes the pop-up window
// and turns off the Window Timers
function closeWindow()
{
// If popUpHover == true then I do not want
// the window to close
if(popUpHover == false)
{
clearInterval(winOpenTimer);
clearInterval(winCloseTimer);
newWindow.close();
}
}
function popUpDetails()
{
// This will be used to prevent the Details Window from closing
popUpHover = true;
// Below is some other javascript code...
}
</script>
彈出一個花哨的工具提示窗口?哎呀!彈出阻止程序會阻止!使用Ajax驅動的工具提示。 – epascarello
我還不熟悉Ajax。但是,這不僅僅是一個奇特的工具提示,它將爲我的個人使用提供有用的信息。如果它不能在Javascript中實現,那麼我將學習和使用Ajax,但我更喜歡javascript中的解決方案。 – yerty