Generate Href target blank link from popup form - html

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!

Related

Change background color of button after sent action (after one click)

Hello I have a contact form I want to do it with PHP. And I have the submit button, I want when all fields are ready to press, when the email was send to change my button. First in my button is a text with background color yellow and the text is "Send". When I press the button and the email is sent I want to change the background color in red and I want to add an icon aside to text, the text is modifed in "Sent". How can I do this?
<script src="jquery.min.js"></script>
<script >
function button(){
//your ajax code for sending data
/* function retrieveData(){
$.post('server.php',{}, function(data){
});*/
$("#button").attr('value', 'Sent');
$("#button").css("background-color","red")
}
</script>
<input type="button" id="button" name="button" value="Send" onclick="button()">
Try this. You can do it with javascript.
You have a form with some inputs and a submit button.
You want to manipulate the submit button after all of the form fields were filled-in, and finally manipulate it again once the submit button was clicked.
What you need to do is to write a little javascript (either plain vanilla or jQuery, choose what suits you best) to handle two things in your form
Your form's input fields (for first submit button change):
Attach an event to the input fields to check for validation as you wish, and change the submit button accordingly.
Your form's submit button (for the second submit button change):
Attach a click event to the submit button (and make sure to prevent the default, so once the submit button was clicked, it will be manipulated in the way you wish.
I have wrote you an example, where in my scenario I have two input in my form and a submit button which is disabled and greyed-out by default.
As soon as all form fields are filled-in (not empty), the submit button becomes active (disable attribute removed and color change) - finally when the submit button is being clicked, it will change it's color to green as an indication that it was clicked.
$('#myForm input').on('keyup',function(){
var validated = true;
$('#myForm input').each(function(){
if($(this).val() === ''){
validated = false;
}
});
if(validated){
$('#submitBtn').removeClass('disabled').prop('disabled',false);
}else{
$('#submitBtn').addClass('disabled').prop('disabled',true);
}
});
$('#submitBtn').on('click',function(e){
e.preventDefault();
e.stopImmediatePropagation();
$(this).addClass('submited').prop('disabled',true);
// the rest of your code for submission..
});
Here's the simple fully working example:
https://jsfiddle.net/wx9gonrh/
Of course you can use this example and modify it to your own needs, or write your own from scratch using this as guidance.
In your case you might want to incorporate an async method for changing the submit button only after the emails were successfully sent (e.g. an ajax complete\done event)
Hope it helps!

How to create a popup window for wordpress that auto redirects my visitors to another site?

I need to find out the code for wordpress to create a popup that auto appears and send the visitors to a specific site.
HTML:
<div class="socials">
</div>
JS:
$(document).ready(function() //when the document is ready load the function
{
$('.socials .fa').click(function(event) //when the object with both classes "fa" and "socials" is clicked
{
event.preventDefault(); //don't follow the URL as normal link!
window.open(this.href, "popupWindow", "width=600,height=600,scrollbars=yes"); //create pop up 600x600 with href of the link
});
});
Don't know if it will run with bootstrap, but it is working jQuery version

Opening template html in a new window from UiApp Script

I have a UiApp script that display images in flextable; I have assigned mousedown handler to the images so that when it is clicked I want it to open a templated HTML page (in a new window). I wrote the following code; it gets executed but it doesnt return anything.
What should I do to get the Item Detail page containing the image loaded from the imageurl assigned to be opened in a new window?
Here's my script and html code:
var page = HtmlService.createTemplateFromFile("Item Detail");
var image = productDetails[i].imageurl;
page.imageurl = image;
Logger.log(productDetails[i].imageurl);
return page.evaluate();
<img src=<?=imageurl ?> alt="click for more info" height="100%" width="100%">
So suppose you want to make a clickable image. And you want this image to open in a new window when you click on it.
var anchor = app.createAnchor("<img src='URL_TO_IMAGE' />",
true,
ScriptApp.getService().getUrl()+"?detailPage="+SOME_ID)
.setTarget("_blank");
Then when you click on that link, your script will be opened in another window. And also, a GET parameter will be passed along with it. So in your doGet(e) function, you could handle whether to display the main UiApp or an Html detail page.
function doGet(e) {
if (e.parameter.detailPage) {
//show the detail page
} else {
//show the normal UiApp
}
}
Read the top part of this other answer to get a better idea of how GET parameters work with GAS.
You will want to surround the <img> with a <a> tag.
<img ... >

submit button open new window and close parent window?

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>

With one click I want to open link in new window and also 2 new tabs in previous window

I want to open image link in new window and also 2 new tabs in previous window at a time .
Kindly tell me how i can do this with html/java script code or whatever way ?
just simply you should add javascript event on image link and use this code;
<a id="test" href="your address for main window"> <img> </img> </a>
<script type="text/javascript">
document.getElementById("test").onclick = function(){
window.open("url to open in new tab",'_blank');
return true;
}
</script>
important to give a return true (or don't using a return in onclick function).
If you wanna do it in only js you can execute two window functions on onclick:
document.getElementById("test").onclick = function(){
window.open("url to open in new tab",'_blank');
window.open("url to open in main window",'_blank');
}
something like that should work. :)
Technically it depends on the individual settings of the users browser to open URLs in tabs or new windows so whatever you use will be subject to those settings and potentially unreliable.