submit button open new window and close parent window? - html

i've basically got a login form, it pops up in a css box asking the user to login. i was having the problem that once the user clicked submit they were being taken to the login window within the css box so made the submit button open a blank/new window.
The problem i have now though is the parent window stays open with the users login details. For security i'd really like to get rid of this, so is there a way i can close the parent window on the launch of the new one? Or even set it so that the page refreshes after the submit button is pressed to clear the css box?
Thanks
Here's what i've got so far:
<form action="login.php" method="post" target="_blank" >

<form action="login.php" method="post" target="_top" >
This will send the form to the parent window, which should completely remove the login box, and reload the parent page as well.

you can also use js
<script type="text/javascript">
function add_tab2(){
var newTab = gBrowser.addTab('http://www.google.com');
newTab.label = "MyTab";
newTab.id = "MyTab";
gBrowser.selectedTab = newTab;
aDoc = document.getElementById("MyTab");
// do something with aDoc here
window.close();
}
</script>

Related

Always hide div if user clicks on a close button

On my WordPress site, I have a notification bar at the top that is displayed to unregistered users. When user clicks a close button, the notification div is simply hidden with display: none;.
The problem is that whenever the user refreshes the page or goes to a different page, it reappears.
My question is, what is the best way to keep this bar always hidden once user clicks the close button? What is good practice in this scenario?
One possible solution is to use local storage:
html
<div>test</div>
<input type="button" value="hide" />
js
$(":button").on("click", function(){
$("div").toggle();
localStorage.setItem("hide", $("div").is(":visible"));
});
localStorage.hide == "false" ? $("div").hide() : $("div").show();
fiddle

Generate Href target blank link from popup form

I want users to input some url in a text field from a popup, and then, when submit the popup the parent page auto refresh and shows the url they have insert, with hyperlink to the site.
I have now set a scrypt to store the form in a cookie, that computer can read everytime users come back to the site.
You can see my work in: http://www.resmasecamadas.com/test
You can achieve it using JS. you dont need to use cookies at all!
Observe this sample code.
//On click of this button new Popup will be opened!
<button onclick="myFunction();">Open popup</button>
<script>
function myFunction() {
var popup = window.open("", "popup", "width=200, height=100");
popup.document.write("<input type='text' name='text' id='text'><button onclick='window.opener.passFunction(text.value);'>click</button>");
}
function passFunction(x){
document.write(x);
}
</script>
You can send data from pop up window using window.opener.someFunction(parameters)here "someFunction" is a function in parent window!

why do I have to click twice to a submit input using selenium

ENV
chrome 32 webdriver2.8
I am using selenium(java) to click a submit input. But I need to click twice to active the submit operation.
The input code:
<input type="submit" disabled="disabled" id="id_submit" name="submit" class="btn-txt" value="OK">
NOT WORK selenium code:
if(submitButton.isEnabled()) {
new Actions(driver).moveToElement(submitButton).perform();
submitButton.click(); // this sentence is executed.
}
WORKS
submitButton.click();
submitButton.click();
Well, the first click function seems to make the button get focus, and the second click function active submit operation. When I use moveToElement to focus the button first, the click not work either. I can ensure that the button is enabled. I want to use selenium to click button and I dont want to do click twice. What should I do? Any ideas? Thanks.
EDIT
WORKS EITHER
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('id_submit').focus();");
jse.executeScript("document.getElementById('id_submit').click();");
UPDATE
Imagine that I want to input a string, say "abcdef123456". Then send_keys is executed. It looks like
and submit button is enabled. After click the submit button at the first time. It looks like and submit button get focus. After click the submit button at the second time, the form is submited and page is redirected. I am confusing about the first click.
have you tried with Expected Conditions class,
new WebDriverWait(driver,30).until(ExpectedConditions.elementToBeClickable(By.id("id_submit"))).click();
It can solved like:
driver.sendkeys("abc1234"); (input in text box)
//explicit wait
WebDriverWait w = new WebDriverWait(driver, 10);
w.until(ExpectedConditions.elementToBeClickable(By.id("Button")));
or
w.until(ExpectedConditions.visibilityOf((WebElement) By.id("Button")));
driver.findElement(By.id("Button")).click();

assistance with html code for popup window

I will be using shopify's system so i am restricted to how and which pages i can edit.
I have one page that is an app but i want that page, on loading, to show a popup disclaimer before they can see the page.
I am told that i can't edit the app page itself but i can add javascript code in the common site footer to check current url and if it equals this certain page, then create a popup.
I have created a page that holds the disclaimer information so i would like the popup window to load this pages' content.
I believe i can load the content using this div tag
div id="popupinfo" pages.disclaimer.content div
I do not know how to add the if statement to check if current url = site.com app.html then div id="popupinfo" pages.disclamier.content div
This site uses their own language called Liquid, hence the double brackets..but any code to pull the content of an html page would work i am sure.
Can i please have some assistance in how i am to
check current page
if page = xxx
best way to create a popup window where the user has to click as yes or ok button
then display the regular page
Thanks in advance!
Brocour
It's only possible to open a pop-up window upon a user-action, for example a 'click' action.
if( document.URL === "myPage.html" ){
// Disclaimer alert
if (confirm('Do you agree to this Disclaimer?')){
// Redirect
window.location = "myNewPage.html";
} else {
// Do nothing
}
}
Try something like this:
<html>
<head>
</head>
<script type="text/javascript">
function poponload()
{
popupwindow=window.open("","mywindow","location=1,status=1,scrollbars=1,width=100,height=100");
popupwindow.moveTo(0, 0);
}
</script>
<body onload="javascript: poponload()">
This is the page
</body>
</html>
You could use the code in this example i made.
$(document).ready(function(){
$('#open_popup').click(function(){
popupwindow=window.open("http://google.com","mywindow","location=1,status=1,scrollbars=1,width=600,height=500");
})
})

How to close a modal box after form submit?

I am using the css modal box described by Paul R.Hayes here - http://www.paulrhayes.com/experiments/modal/
I have inserted a form into the modal box. The form target is in an iframe which is hidden on the same page. I want to close the modal window as soon as the form submits. But the form should be processed within the iframe (hidden).
How can I achieve this?
It looks like the modal window is closed by any url linking to the #close html fragment.
Therefore adding the following code to the submit handler of your form should close the modal on submission.
<form ... onsubmit="window.location.assign('#close')">
I assume the close button of the modal button calls a Javascript function. For instance "CloseModal()".
In your form tag, you can use the following code to call that function:
<form name="myform" action="myconfpage.extension" target="iframe" onSubmit="CloseModal();">
This will call the close function on submitting of the form.