I'm attempting to execute the following JavaScript function(pop up a new window) when clicking on an image but doesn't work. can you please help me correct the code?
<script language="javascript">
var win = null;
function NewWindow(wizpage, wizname, w, h, scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition +
',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
win = window.open(wizpage, wizname, settings)
}
</script>
<FORM>
<INPUT TYPE="Image" SRC="https://communities-
qa.connect.te.com/sites/GP/Indirect/PublishingImages/clickhere2.jpg"
Alt="Contact Us" onClick="
NewWindow('www.google.com','name','590','390','yes');return false"></FORM>
thanks a lot
Blocked opening 'https://www.google.com/' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
var win = null;
function NewWindow(wizpage, wizname, w, h, scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition +
',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
win = window.open(wizpage, wizname, settings)
}
<FORM>
<INPUT TYPE="Image" SRC="https://communities-
qa.connect.te.com/sites/GP/Indirect/PublishingImages/clickhere2.jpg"
Alt="Contact Us" onClick="
NewWindow('https://www.google.com','name','590','390','yes');return false"></FORM>
Related
I need some help getting my code working.
I am trying to Track the Clicks on my custom FB Share Button.
I need to implement this code:
onClick="ga('send', 'event', 'category', 'action', 'ShareFBButton');">
This is my code:
<script type="text/javascript">
function fbs_click(width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 10);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",
resizable=yes,left="
+ leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition +
",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;}
</script>
<a href="http://www.facebook.com/share.php?u=<?php the_permalink()?>"
onClick="return fbs_click(570, 300)" target="_blank" title="ShareOnFacebook">
<img src="images/shareonfacebook.png" width="614" height="54"
alt="ShareOnFacebook"></a>`
Just add it into callback body:
<script>
function fbs_click(width, height) {
ga('send', 'event', 'category', 'action', 'ShareFBButton');
/*....
....
.... rest of script
....*/
t=document.title;
window.open('http://www.facebook.com/sharer.php? u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;}
</script>
I need to disable click of the Youtube iframe or set difference click,.
I tried to put a div in front the iframe but it doesn't work.
Here is my code, works in Chrome but not in Mozilla:
$(".youtube").each(function () {
var div = this;
var offset = $(this).offset();
var x = offset.left;
var y = offset.top;
var height = $(this).height();
var width = $(this).width();
var divInFront = '<div style="position:absolute; height:' + height + '; width:' + width + '; top:' + y + '; left:' + x + ';" ></div>';
$("body").append(divInFront);
});
I have a function that pops up window in the center and I want it to have a vertical scrollbar.
function popUpCal()
{
var url = "calendar_flight_maint.php";
var width = 700;
var height = 600;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
window.open(url, "subWind", windowFeatures, "POS", "toolbar=no", "scrollbars=1");
}
I have tried scrollbars=yes, scrollbars=auto, scrollbars=1 but the scrollbars still aren't appearing. Is there something wrong with my code? I'm using Firefox 21.0 and I've already tested it in IE 8. What seems to be the problem?
As seen in the specs for window.open, your parameters are wrong.
Try this:
function popUpCal()
{
var url = "calendar_flight_maint.php";
var width = 700;
var height = 600;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height +
",status,resizable,left=" + left + ",top=" + top +
"screenX=" + left + ",screenY=" + top + ",scrollbars=yes";
window.open(url, "subWind", windowFeatures, "POS");
}
Here is a jsFiddle
The following code works well and launches a facebook popup on the screen, however this popup is not centered.
<script type="text/javascript">
function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}
</script>
<img src="images/facebookimage.jpg" alt="facebook share">
Here is the script that centers a popup window:
<script type="text/javascript">
function MyPopUpWin(url, width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
//Open the window.
window.open(url, "Window2",
"status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
+ leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
+ topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
}
</script>
How can I update the first script so that it works in combination with the second script to result in the popup window launching in the center of the screen?
See if this works for you:
<script type="text/javascript">
function fbs_click(width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;
}
</script>
<!-- Please change the width and height to suit your needs -->
<img src="images/facebookimage.jpg" alt="facebook share">
Try this
<script type="text/javascript">
function fbs_click() {
u=location.href;t=document.title;window.open(
'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer','toolbar=0,status=0,width=626,height=436');return false;
}
</script>
Share on Facebook
Or this post with a picture on Facebook
<script type="text/javascript">
function fbs_click() {
u=location.href;t=document.title;window.open(
'http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer','toolbar=0,status=0,width=626,height=436');return false;
}
</script>
<img src="http://originus.samsung.com/us/images/support/facebook-share.png"/>
You can change the image or words
Size pop-up window
width=626,height=436
You can change the size
I'm trying to open a javascript popup that is centered based on where the current window is. I have dual monitor setup and it works in every other browser but chrome. For some reason when chrome is on my 2nd monitor the popup is way to the right.
var winX = (document.all) ? window.screenLeft : window.screenX;
var winY = (document.all) ? window.screenTop : window.screenY;
var newWindowWidth = 650;
var newWindowHeight = 700;
var currentWindowWidth = $(window).width();
var currentWindowHeight = $(window).height();
var newWindowX = (winX + (currentWindowWidth / 2)) - (newWindowWidth / 2);
var newWindowY = (winY + (currentWindowHeight / 2)) - (newWindowHeight / 2);
window.open("", "configurationWindow", "scrollbars=1,resizable=yes,width=" + newWindowWidth + ",height=" + newWindowHeight + ",top=" + newWindowY + ",left=" + newWindowX);
This is a known Chrome bug, id #73353. If you have a Google account you can star it to keep track of its status.