I have a button that is connected a JS function to operate SSO for another website. The button works when popup blocker is disabled, however it no longer works when popup block is turned on. How do I get onClick to work while the popup blocker is activated? Below is my code:
HTML
<input class="btn btn-primary btn-lg" type="button" value="Launch AdEase" onClick="postURL()" />
Javascript
function postURL() {
var idOfClientFirm = document.getElementById('mfID').value;
document.getElementById('<%= txtField2.ClientID%>').value = idOfClientFirm;
document.getElementById('<%= loginLinkButton.ClientID%>').click();
}
Related
I have a page where a <button> is kept on which onClick() event fires and redirects the new page in new tab. Meanwhile I want the parent page to close itself as soon as the <button> is clicked with opening the new page in new tab. Its basically for some security feature for the website. How can this be done?
Here is my <button>, let me know where can i correct myself.
<button formtarget="_blank" type="submit" name="submit" onClick="javascript:window.open('quiz.php?unit_id=<?php echo $fnc->encode($unit_id) ; ?>');self.close();" value="submit" class="btn btn-info" style='margin-left: 35%;margin-bottom: 10px;' ><i class="glyphicon"></i> Start Quiz</button>
you can close window by below function
function close(){
setTimeout("window.close()", 500);
}
But keep in mind that : Scripts may close only the windows that were opened by it.
The window close and open new tab
<script language="javascript">
function quitWindow(cmd)
{
if(window.open("your_new_tab_page.htm")){
if (cmd=='quit')
{
open(location, '_self').close();
}
}
return false;
}
</script>
<input type="submit" onclick="return quitWindow('quit');" value="Close This Window and open new Tab" />
If you use firefox, you should about:config by writing url bar and set
dom.allow_scripts_to_close_windows = true
otherwise does not work firefox
I think this might work.
<script>
function openWindow( url )
{
window.open(url, '_blank');
window.focus();
window.close();
}
</script>
<button onclick="javascript:openWindow(yourHref);return false;">Submit</button>
You cant close your webpage if the user clicked the link of your website from any other place other than your website, due to security reasons.
On an xpage I have a dialog which I want to open from csjs.
In the DDE KC it is explained as followed:
https://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.0/com.ibm.designer.domino.ui.doc/extlib_controlref_dialog.html
So I added two buttons. One HTML and one Button control:
<button onclick="openDlgAction('1')">Open Dialog</button>
<xp:button value="Open Dialog" id="button4">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.openDialog("#{id:dlgAction}")]]></xp:this.script>
</xp:eventHandler>
</xp:button>
Here is how my dialog is rendered:
<span id="view:_id1:_id2:cbMain:dlgAction" style="display: none" title="Select Action"></span>
In order to generate the correct ID in my openDlgAction CSJS function I added it to the Xpage via a script block.
Here is how it is rendered in the browser:
<script type="text/javascript">
function openDlgAction(unid){
XSP.openDialog("view:_id1:_id2:cbMain:dlgAction")
}
</script>
The function under the Button control is rendered as followed:
function view__id1__id2_cbMain__id319_clientSide_onclick(thisEvent) {
XSP.openDialog("view:_id1:_id2:cbMain:dlgAction")
}
What I do not understand is why the Button control works (dialog appears) and under the HTML button the page refreshes quickly.
Out of curiosity I added another HTML button with an onclick event which also refreshed the xpage:
<button onclick="alert('hi')">click me</button>
What am i overlooking?
The page reloads when you click the "html buttons" because the buttons do not specify a button type. It's therefore interpreted as a submit button.
So set the button type to 'button':
<button type='button' onclick="openDlgAction('1')">Open Dialog</button>
I've been trying to navigate a page to another page in the same window (web browser = Google Chrome, Mozilla Firefox and Internet Explorer) using button. The steps are,
The page will popup message for confirmation.
If the user click ok, then the page will navigate to other page in the same tab/window.
If the user click cancel or x, it stays on the current page.
I have tried using
window.open("home.php","_self"); and window.location.href="home.php"; and document.location.replace("home.php"); and location.replace("home.php"); and location.assign("home.php");
but it doesn't work. How do I fix this?
<span title="Click to register the new user"><button type="submit" id="submit" onclick="myFunction()">Register User</button></span>
<script>
function myFunction() {
confirm("Proceed?");
window.open("home.php");
}
</script>
Problem seems to me is, possibly you are using form with button which leads to reload.
<button type="submit" id="submit" onclick="myFunction()">Register User</button>
Make the type="submit" to type="button". Also major browser do have popup blocker enabled where this line may fail window.open("home.php");
Small change in script as follows:
function myFunction() {
if(confirm("Proceed?")) //<--- ok/yes = true, no/cancel/close = false
location.href = "home.php";
}
Small demo:
var ask = function() {
if (confirm('Proceed ?'))
location.href = "http://espn.go.com/";
};
<button onclick="ask();">Watch ...</button>
window.location.href
is not a function . You have to use it as
window.location.href="home.php";
Updated your code and this works
<span title="Click to register the new user"><button type="submit" id="submit" onclick="myFunction()">Register User</button></span>
<script>
function myFunction() {
if( confirm("Proceed?") )
window.location.href="home.php";
}
</script>
I have a Customer Info form that has anchor tag "close" that should close the current window. This customer form is being opened as pop up. The Customer form also has a search btn that when clicked it pop ups the search form that is being run by a javascript called searchOrder.js. So basically it is a pop up inside a pop up. The customer form's close btn is not working but when the reference to searchOrder.js is removed, it begins to work. Also, when the search pop up is open and I click the "close" anchor tag, it closes the search pop up but never the current window which is the customer form.
Ive tried a lot of solutions already but nothing is working. I used self.close(), window.opener.close(), made it a btn instead of a link etc.,c alled a function onclick
function closeWindow() {
var closeRef;
window.opener='x';
closeRef = window.open('','_parent','');
//or closeRef = window.open("",name);
closeRef.close();
}
heres my gsp code:
<g:form method="post" name="CustomerInfoForm" target="_parent" role="form">
<div class="id="closeLink">Close</div>
<button id="searchOrderButton" type="button" class="button" onclick="searchOrder(document.forms[0].summaryMessage.value,'summaryMessageText','${createLink(action:'searchOrder')}','${createLinkTo(dir:'images',file:'closeButton.gif')}')" value="Search Order">Check Order</button>
</g:form>
How do I make the current window (customer info ) close? tnx
You should use a function like this to close your popup window :
<g:form method="post" name="CustomerInfoForm" target="_parent" role="form">
<div class="id="closeLink">
Close
</div>
<button id="searchOrderButton" type="button" class="button" onclick="searchOrder(document.forms[0].summaryMessage.value,'summaryMessageText','${createLink(action:'searchOrder')}','${createLinkTo(dir:'images',file:'closeButton.gif')}')" value="Search Order">Check Order</button>
</g:form>
<script type="text/javascript">
function openpopup()
{
my_window = window.open("","myPopup","status=1,width=100,height=100");
}
function closepopup()
{
if(false == my_window.closed)
{
my_window.close ();
}
}
</script>
EDIT : Don't forget to open your popup with the openpopup() function :
Open Popup Window
You can shorten window.close() to just close() and shorten window.open() to open(). Maybe you'll find what you need here, though:
http://www.w3schools.com/js/tryit.asp?filename=try_win_closed
http://www.w3schools.com/jsref/obj_window.asp
I am developing a web application which is compatible with iPad.
Earlier I was testing on iOS version 3.2, and all modal dialog popups are returning values just fine to the parent window. But after upgrading my iOS to 4.3, it is behaving odd. Now, on iPad, it is returning a value, but is not updating the field until I click on another field or the same field (HTML text field).
I am opening modal popup using window.open();
And returning using window.opener.oaEventiPad(retValArray);
oaEventiPad is function which is responsible for setting updated value.
Can anyone please help ??
Thanks,
I am through the similar issue. I open a popup suing window.open in my asp .net application which is supposed to be compatible with iPad. Value has successfully been returned when I use IE, Chrome, FireFox and Safari (on PC with windows 7).
Unfortunately the same code fails in Safari when I access the application through iPad. On iPad domObject is prompted on new window open instead of prompting returned value on new window close.
Below is the code.
Parent Window:
enter code here
<script type="text/javascript">
function modalWin() {
//alert('clicked');
if (window.showModalDialog) {
retVal = window.showModalDialog("About.aspx", "name", "dialogWidth:255px;dialogHeight:250px");
alert(retVal);
}
else {
retVal = window.open('About.aspx', 'name', 'height=255,width=250,toolbar=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no ,modal=yes');
alert(retVal);
}
}
</script>
//HTML
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<a title="Test New Popup" onclick="modalWin();">New Popup for all browsers.</a>.
</asp:Content>
New Page:
<script type="text/javascript">
function closeIt(tempValue) {
window.returnValue = tempValue;
window.close();
}
</script>
//HTML:
<input id="btnButton1" value="btnButton1" type="button" title="Press it to Close" onclick="closeIt('btnButton1');" />
<br />
<input id="btnButton2" value="btnButton2" type="button" title="Press it to Close" onclick="closeIt('btnButton2');" />
<br />
<input id="btnButton3" value="btnButton3" type="button" title="Press it to Close" onclick="closeIt('btnButton3');" />