What I am trying to do is to make that so when the link taht is generated is clicked, a new javascript window pops up with a predefine size.. I tried using this code: (Changing the link with Javascript)
The reason you get the second ("normal") window is because you're allowing the browser to perform the normal click behaviour on a link (go to the URL in the href attribute) after executing the onclick handler. You should return false from the handler to prevent this:
Javascript to have new window for link
Hi There,
I have an XSLT with the following code in it:
<xsl:variable name="mediaId" select="number($product/data[@alias='productAnimation1'])" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="count($mediaNode/data) > 0 and string($mediaNode/data[@alias='umbracoFile']) != ''">
<a href="{$mediaNode/data[@alias='umbracoFile']}"><xsl:value-of select="$mediaNode/@nodeName"/><a/>
</xsl:if>
</xsl:if>
What I am trying to do is to make that so when the link taht is generated is clicked, a new javascript window pops up with a predefine size.. I tried using this code: (Changing the link with Javascript)
<a href="{$mediaNode/data[@alias='umbracoFile']}" target="_blank" onclick="MM_openBrWindow('{$mediaNode/data[@alias='umbracoFile']}','test1234','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=200,height=100')">test
Then I added a head script tag that was this:
<script type="text/javascript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
The result of this is that it opens up two windows one with the predefined size, and one that is full sized...
Any thoughts??
Thanks For your help
Try changing
<a href="{$mediaNode/data[@alias='umbracoFile']}" target="_blank" onclick...
to
<a href="#" onclick...
Rich
Hi Vincent,
The reason you get the second ("normal") window is because you're allowing the browser to perform the normal click behaviour on a link (go to the URL in the href attribute) after executing the onclick handler. You should return false from the handler to prevent this:
(I've also used this.href so you only have to remember to update the URL in one place)
/Chriztian
is working on a reply...