PDA

View Full Version : script Open offsite links in new window not working with pop rollovers



surfer
03-28-2013, 03:31 PM
1) Script Title: Open offsite links in new window

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/newwindow2.htm

3) Describe problem:
The script works excelent for links that are on text.
**Example**

<div class="Artistic-Body-P">
<span class="Artistic-Body-C">
<a href="http://externallink.com" style="text-decoration:none;">test</a>
</span>
</div>

but it's not working for links that are within div rollover.
**Example**

<div id="div_popup_roll_13" style="position:absolute;left:109px;top:259px;width:76px;height:76px;">
<a href="http://externallink.com" rev="image1.png~#~-14~#~-15~#~text~#~148~#~-119~#~#949393~#~Tahoma~#~30~#~0~#~1~#~transparent~#~165">
<img src="image2.png" border="0" width="76" height="76" id="popup_roll_13" alt="">
</a>
</div>

I have been busting my head for many days how to fix this, but guess that the fact that I'm beginner, doesn't help so I decided to post here.




here is the code from poproll:

(function($){jQuery.fn.poproll=function(settings){var m_bHovering=false;var m_nDivId=0;
var $m_ImageDiv=null;var $m_TextDiv=null;
var eOptions={Img:0,ImgPosX:1,ImgPosY:2,Txt:3,TxtPosX:4,TxtPosY:5,TxtCol:6,TxtFont:7,TxtSize:8,TxtItallic:9,TxtBold:10,TxtBkgrndCol:11,TxtWidth:12};
function ClosePopup(){if($m_ImageDiv!==null){$m_ImageDiv.remove();
$m_ImageDiv=null;if($m_TextDiv!==null){$m_TextDiv.remove();
$m_TextDiv=null}}}function HoverOver(div){m_bHovering=true;var nDivId=$(div).attr('id');
if(nDivId!==m_nDivId){m_nDivId=nDivId;ClosePopup()}if($m_ImageDiv===null){var anchor=$(div).find('a');
var optionArray=$(anchor).attr('rev').split('~#~');
var href=$(anchor).attr('href');
if(href===undefined){$(div).append('<div id="poproll_img" style="position:absolute; left:'+optionArray[eOptions.ImgPosX]+'px; top:'+optionArray[eOptions.ImgPosY]+'px; z-index:100;"><img src="'+optionArray[eOptions.Img]+'" name="popup_roll_2" alt="" style="position:absolute;left:0px;top:0px;"></div>')}else{$(div).append('<div id="poproll_img" style="position:absolute; left:'+optionArray[eOptions.ImgPosX]+'px; top:'+optionArray[eOptions.ImgPosY]+'px; z-index:100;"><a href='+href+'><img src="'+optionArray[eOptions.Img]+'" name="popup_roll_2" alt="" border="0" style="position:absolute;left:0px;top:0px;"></a></div>')}$m_ImageDiv=$('#poproll_img');
if(optionArray[eOptions.Txt].length>0){var fontStyle=optionArray[eOptions.TxtItallic]>0?'italic':'normal';
var fontWeight=optionArray[eOptions.TxtBold]>0?'bold':'normal';$(div).append('<div id="poproll_txt" style="position:absolute; left:'+optionArray[eOptions.TxtPosX]+'px; top:'+optionArray[eOptions.TxtPosY]+'px; width:'+optionArray[eOptions.TxtWidth]+'px; color:'+optionArray[eOptions.TxtCol]+'; font-size:'+optionArray[eOptions.TxtSize]+'; font-family:'+optionArray[eOptions.TxtFont]+'; font-style: '+fontStyle+'; font-weight:'+fontWeight+'; background-color:'+optionArray[eOptions.TxtBkgrndCol]+'; z-index:100;">'+optionArray[eOptions.Txt]+'</div>');$m_TextDiv=$('#poproll_txt')}}}function HoverOut(){m_bHovering=false;window.setTimeout(function(){if(!m_bHovering){ClosePopup()}},100)}this.hover(function(){HoverOver(this)},function(){HoverOut()})}}) (jQuery);


All help and suggestion is appreciated in advance.
THNX

molendijk
03-28-2013, 04:37 PM
This, maybe?

<div id="div_popup_roll_13" style="position:absolute;left:109px;top:259px;width:76px;height:76px;">
<a href="http://externallink.com" rev="image1.png~#~-14~#~-15~#~text~#~148~#~-119~#~#949393~#~Tahoma~#~30~#~0~#~1~#~transparent~#~165">
<img onclick="window.location.href='http://externallink.com'" src="image2.png" border="0" width="76" height="76" id="popup_roll_13" alt="">
</a>
</div>

surfer
03-28-2013, 05:11 PM
Thank you very much for prompt reply, just tried the solution you suggested, unfortunately it's not working.
Do you have some other suggestions that I can try?

molendijk
03-28-2013, 10:10 PM
Well, the DD script is not the problem since the following works (I'm using your own solution together with a small modification):

<script type="text/javascript" src="ddwindowlinks.js">
/***********************************************
* Open offsite links in new window- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

<div id="div_popup_roll_13" style="position:absolute;left:109px;top:259px;width:76px;height:76px;">
<a href="http://externallink.com" >
<img src="http://img.youtube.com/vi/AVgbEkBWuqs/0.jpg" border="0" width="76" height="76" id="popup_roll_13" alt="" onmouseover="this.src='http://img.youtube.com/vi/AVgbEkBWuqs/3.jpg'" onmouseout="this.src='http://img.youtube.com/vi/AVgbEkBWuqs/0.jpg'">
</a>
</div>