trying to get my popup window blocked (need alt. to "window.open") - javascript

I'm working with the facebook SDK and it works through popups due to security issues now.
So I've got a button that deals with facebook [FacebookButton] which is hidden, and a button to test for popup blocker [PopupTester].
My code is like this,
when [PopupTester] is clicked, if a popup works: close it, hide this button, and show [FacebookButton].
or
when [PopupTester] is clicked, if popup fails, show dialogue to urge to change popup settings, keep [FacebookButton] hidden, change this button value to [Try Again].
function testPopupBlocker() {
var windowName = 'userConsole';
var popUp = window.open('http://www.whirlocal.com', windowName, 'width=200, height=200, left=24, top=24, scrollbars, resizable');
if (popUp == null || typeof(popUp)=='undefined') {
var weGood = "nope";
alert('Please disable your pop-up blocker and click the link to test again.');
}
else {
var weGood = "yup";
popUp.close();
}
}
This works great, except for the fact that this button always creates a popup, but the Facebook one is still being blocked!
Is there another method besides "window.open" to create a popup? One that is more likely to be blocked?
EDIT:
Here's my button codes
<input type="button" class="genButton testPopupButton" name="Test Popup Blocker" title="Test Popup Blocker" value="Test Popup Blocker" onclick="testPopupBlocker()" style="cursor:pointer;" />
<input type="button" class="genButton needsPopups facebookButton" name="AdvocateOnFacebook" title="Recommend <?php echo genesis_get_option('organization','child-settings');?> on Facebook" value="Recommend us on Facebook!" onclick="advocateToFriends()" style="cursor:pointer; display:none;" />

You need to legitimize the popup. It needs to be initiated by the user, and not arbitrary popup code, or else a popup blocker will stop it. Once you have a handle on the popup, then you may modify it however you like.
Try this html code out:
<a href="#" onclick="javascript:window.open('http://myurl.com/blank_page.html','userConsole','width=800,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=auto,resizeable=yes');">
<div class="some_div_class"><b>Click Me</b></div>
</a>
Then run your testPopupBlocker() function and see if it works a little better.

Related

Re-direct page to fb

Hello I am designing a landing page for my company.. We have ads on FB. we have button on fb when click on that button our landing page opens.
We have 2 option on page one with yes button which will open form and no button should close browser and re direct to fb page.. plz help how can i re-direct it to fb.
<button class="btn-yes">Yes</button>
This is my button which should be re-directed to fb.. plz help if possible with javascript, jquery.
thanks
You can use this jQuery code for your button.
$('.btn-yes').click(function() {
window.location.href = 'your fb link';
return false;
});
Add link to assign window.location.href.
You can use tag
<button class="btn-yes">Yes</button>
If you want to open it in new page
<a target="_blank" href="{your fb link}"><button class="btn-yes">Yes</button></a>

Hide a Radbutton which is inside a popup when another popup form is submitted and closed upon OnClientClicking

I have a page "Main2.aspx" and inside this page, I have a button "Transactions" upon clicking this button opens a popup form "Transactions" and Inside this popup, I have coded a button "AddRadbutton" and Upon clicking this "AddRadbutton" on using Javascript URL redirection a new popup "SaveDetails" form will appear.
This "SaveDetails" form is having a "SaveRadButton", upon clicking this "SaveRadButton" my form details will be saved and the popup closes successfully.
The problem I'm facing here is, "AddRadbutton" on the "Transactions" form is still visible even after filling and submitting the details using "SaveRadButton" on "SaveDetails" form.
Earlier, I'm able to achieve the same scenario by coding on Server Side, when I have used the same "SaveDetails" popup page in User Control Page which is inside "Main1.aspx" but not here on Main2.aspx.
In Main2.aspx page I can only achieve this only when page refresh happens. but I need this "AddRadbutton" to be Hidden Immeadiately after submitting the form in "SaveDetails" popup form.
Techniques I've tried so far:
Below is the Code for AddRadButton (which is in Transactions popup)
<div id="AddDetailsDiv" runat="server" visible="true" style="width: auto; height: auto; float: left; margin-right: 10px;">
<telerik:RadButton ID="AddRadButton" runat="server" Text="Add Details"
CausesValidation="False" TabIndex="14" OnClientClicking="showDetailsWindow" UseSubmitBehavior="false" >
</telerik:RadButton>
</div>
Below is the Code for SaveRadButton (which is in SaveDetails popup)
<telerik:RadButton ID="SaveRadButton" runat="server" Text="Save" OnClick="InsertRadButton"
In Server Side for OnClick is there any chance of handling this issue using below line:
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "RadWindow", "CloseBind();", true);
I've tried coding another Javascript function and use it in OnClientClicking or OnClientClicked and call both functions but unable to achieve it because Telerik UI is not supporting or I might be missing something else.
I've tried this basic AddRadButton.Visible = false on server side, its working, but only after page refresh but I needed it to be hidden Immeadiately after popup form submission.
I've tried handling in the below code() but unable to achieve it.
function CloseBind() {
var oWindow = GetRadWindow();
oWindow.close();
oWindow.BrowserWindow.loadDetails();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
I've searched and tried many stackoverflow-related questions, scenarios and also on many community developer sites but those didn't help me either.
Any Ideas or suggestions would be appreciated.
AddRadButton.Visible = false
should work. You will need to make sure that it's inside an if which checks for IsPostback. If that does not work for you, then it's possible that a later event in the WebForms lifecycle overrides it, maybe a render-related event is where this should be implemented, like OnPreRender. You could also register a callback script (see How can I do a call back to the code behind method using javascript (properly)?) and invoke a Javascript functions that changes the display styling to none.
I've tried to solve the problem by introducing an alert() before the window is closed so that the page refresh happens upon alert "OK" button click from the user side.
I've tried by calling an alert function in telerik: RadWindow using OnClientClose="saveDetailsWindowClose"
<telerik:RadWindowManager EnableShadow="true" Behaviors="Maximize, Close" ID="MainRadWindowManager"
DestroyOnClose="false" Opacity="100" runat="server" Modal="true" AutoSize="false"
CssClass="lte_colpopup" KeepInScreenBounds="true" RestrictionZoneID="MainContent"
VisibleStatusbar="false" style="overflow: hidden !important">
<Windows>
<telerik:RadWindow ID="MyRadWindow" ReloadOnShow="true" ShowContentDuringLoad="false" OnClientClose="saveDetailsWindowClose"
Width="950" Height="450" runat="server" Title="Person Details">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
<telerik:RadScriptBlock ID="MasterScriptBlock" runat="server">
I've used below simple Javascript function to alert the User:
<script type="text/javascript">
function saveDetailsWindowClose(sender, args) {
alert('A Screen refresh is mandatory to load the details, so please click "OK" button to proceed');
window.location.reload();
}
</script>
</telerik:RadScriptBlock>
This is how I solved the Issue, fortunately, AddRadbutton on both these Main1.aspx and Main2.aspx and also on popup pages are working as intended. Luckily it didn't hamper with the closing of a window in UserControl Page on Main1.aspx which is using the same saveDetails.aspx page.

HTTP Authentication popup doesn't shows up

I'm trying to load a snapshot of a camera and i want the authentication popup to show up when i click the button, but it doesn't work. i'm following this example https://www.httpwatch.com/httpgallery/authentication/
The popup shows up when i go to http://192.168.100.103:8080/snapshot.jpg but it doesn't when i click on the button.
<script type='text/javascript'>
function getit() {setTimeout(function(){ document.getElementById('downloadImg').src = ('http://192.168.100.103:8080/snapshot.jpg?' + Math.random().toString(10));}, 1000);}
</script>
<img id="downloadImg">
<input type="button" class="button1 buttonspace" value="Display Image" id="displayImage" onclick='getit()'>
Even though the code works when i sign in, i would like that the authentication popup shows up when i load the image.
What am i doing wrong?

How to make a Onclick Full Page Script not work on certain Function in PHP

I was given a onclick Fullpage Popup Ad code
<script type="text/javascript" src="//dolohen.com/apu.php?zoneid=2458038"></script>
It works on the whole page and when someone clicks on any part, it opens up a popup.
Now, I don't Want it to work on the Button, cause when someone clicks it, instead of opening the youtube URL, he goes to dolohen link and has to re-click the button to go to youtube URL!
My problem is I don't want this to work on this function:
function buttonOnClick()
{
window.open('https://www.youtube.com/channel/".$channelID."?sub_confirmation=1', '_blank');
setTimeout(aTagChange, 3000);
}
<button onclick="buttonOnClick();" onmouseover="mouseOver();" onmouseout="mouseOut();">Subscribe <i id="ytb" class="fa fa-youtube-square ytb"></i></button>

facebook connect redirect after invite friends

can I have a question about how to redirect the page after user invite their friends?
i have a code like this: (in javascript)
function inviteFriends(){
if(isBusy) return false;
isBusy = true;
$(".musicPlayer").addClass("invisible");
var fbsc = '<fb:request-form
action="apps.facebook.com/yourapp?pageid=thanks"
target="_self"
method="post"
nvite="true"
type="Contest"
content="Come and Join this contest!"> <fb:multi-friend-selector
target="_self"
showborder="false"
max="30"
import_external_friends="false"
email_invite="false"
cols="5"
actiontext="Invite your friends!" /></fb:request-form>';
var uiSize = FB.UIServer.Methods["fbml.dialog"].size;
FB.UIServer.Methods["fbml.dialog"].size = {width:625};
FB.ui({
method:'fbml.dialog',
display: 'dialog',
fbml: (fbsc),
width: '625px'
},function(response) {
$(".musicPlayer").removeClass("invisible");
window.location = "?pageid=thanks";
isBusy = false;
});
}
that script will call fbml window with facebook's invite friends dialog inside facebook dialog window.
what i want is:
when you close the window (press x at top right corner) it'll redirect to: ?pageid=thanks (this is works with the script above)
when user press the skip button on invite friends dialog it'll redirect to: ?pageid=thanks (this is not working - It'll redirect to ?pageid=thanks but inside the fbml window)
when user have done inviting their friends, it'll also redirect to: ?pageid=thanks (this is also not working - it'll redirect to ?pageid=thanks but in new window -.-!)
am I miss something on my script above, or I'm using the wrong way?
I'd like to achieve this for at least in IE and Firefox
is anyone have done with this before? I really need your suggestion,
EDIT:
if i put:
<fb:request-form target="_top" blah...> <fb:multi-friend-selector target="_self" blah...>
The skip button is working :) but still, after you're done inviting your friends it'll redirect to a new window
If I Put:
<fb:request-form target="_top" blah...> <fb:multi-friend-selector target="_parent" blah...>
This is work if you invite your friends, but not if you press the skip button -.-!
I reckon this is because of facebook open-up another dialog window when you click invite your friends (to preview before you click send)
so the structure level was different between skip button and send button (i hope you got what I'm write)
Thank you in advance
AnD
This is The answer :)
var fbsc = '<fb:request-form action="url here" target="_top" method="post" invite="true" type="Contest" content="blah...">
<fb:multi-friend-selector target="_top" showborder="false" max="30" import_external_friends="false" email_invite="false" cols="5" actiontext="Join NOW to WIN!" /></fb:request-form>';
Note: target="_top"
Try changing target="_self" to target="_parent" i'm not sure that is exactly what you need but the target is the relevant parameter here.

Categories