How to Redirect after Click on Button - redirect

I'm using Landing page so I already have button I want to redirect people after clicking on this button the button id is: button-c86b272c I want to redirect people after clicking on this button not create new button .
I have this code to redirect after time out :
<meta http-equiv="refresh" content="10; URL=www.google.com/" />
but I want one to redirect after click on exicting button not new button I tried change the first code to this :
<meta http-equiv="refresh" onclick="button-c86b272c; URL=www.google.com/" />
but it did not work something isn't right
Hope You help me

The meta tag is not a visible DOM element, it means it does not have a "body", thus cannot be clicked on. meta tag is used to describe metadata about your page, or set HTTP headers.
To redirect to a specific URL after the button is clicked you can use JavaScript:
// First we need to create a handle to the DOM element
const buttonElement = document.getElementById("button-c86b272c");
// Then we add an event listener, which will execute a passed function after the event (in our case "click") is fired
buttonElement.addEventListener("click", () => {
// We set the destination URL, the page reloads automatically
window.locaton = "www.google.com/";
});
Add this code to your page or put it in a separate file and make sure to import it or you can add the event listener directly in your HTML using the onclick property, like this:
<button id="button-c86b272c" onclick="window.location = 'www.google.com/'"></button>
However this approach is not recommended and it's best to put your JavaScript in a separate file and not mix it into the HTML.
Hope this helps!

Related

How to add action to the button created using inboxsdk in gmail inbox?

I have created the button in the gmail inbox using inboxsdk.
Now i want to get a pop up by clicking on that button
2.Pop up should contain a link which navigates to my website page(xyz.com/login.php)
How can i do these using inboxsdk
Screenshot:
If you are still struggling with this, I would suggest a simple solution which is to fire a JavaScript confirm dialog see here. On confirmation you could redirect the user, using window.location.href = '<your-url>';.
Another solution would be to use InboxSDK's widgets.
Example:
InboxSDK.load(2, '<InboxSDK-app-id>').then((sdk) => {
...
const el = document.createElement('div');
el.innerHTML = 'Link description';
sdk.Widget.showModalView({
title: 'Modal Title',
el
});
});
For more ModalOptions look here.
Notice: I set the attribute target attribute of <a> tag to "_blank". This makes sure the url opens in another browser tab.
A third, more direct (optional) solution would be to add an onClick event listener to which you attach a function that redirects the user to your url, see a code example here.
A fourth and better possible solution would be to add a DropdownView to your button's onClick function, see example code here.

How to reset form after form submitting?

I have one search form with search button and some field, when I put value in form field and click on search button then come back on form by clicking on link(modify search form) then form value does not reset...Please check it here(http://dev.viawebgroup.com/search/)
Thanks
Try this:
<script>
function test(){
var input = document.getElementById('search');
input.value = '';
};
</script>
Add onload to the body:
<button onclick="test()">Clear</button>
Add id to input field:
<input type="text" id="search">
Fatal flaw rests form befor data is sent
The simplest way I found is
onsubmit="this.reset()"
Just put this in the form tag and all's well, simple yet efective.
I someone wanted a button excluesivly for form reset I would use onclick and write the reset in a function like this.
function clform()
{
documentgetElementById('myform').reset();
}
The first is tried and true, the second I just wrote but should work.
The function works well used in a onbeforeunload event in the body.
I have been working on this problem my self because the page I wrote is dynamically updated and was keeping form data when back button of browser was used. I also used PHP to reload the page after submission and onfocus to reload the page when form is selected so input is on a fresh page and not the dynamically updated page.

CKEditor - Inserts Blank Content into the Database on First Click on the Save Button

Since this morning am trying to make this work, but failed. The CKEditor appears perfectly into the textarea, but when I try to save the content on the first mouse click on the save button, it doesn't inserts the content into the database. When I trigger my second click on save button again on the same content then its does insert into the database.
Textarea
<textarea class="txtPageContent" name="pageContent" id="pageContent"></textarea>
JavaScript Included
<script type="text/javascript" src="plugins/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
CKEDITOR.replace( 'pageContent' );
</script>
Plead do let me know for more informations.
Call CKEDITOR.instances.pageContent.updateElement() first (see docs).
This will synchronize your textarea and your editor in terms of the content. Then, your AJAX request should serialize correct data. Just make sure that updateElement() call is before you gather data.
i have tried this. it works.
function returnToSubmit() {
$('#ckeditor').val(CKEDITOR.instances['ckeditor'].getData();
}
Also take a look into this SO

rails 3 - Add a Button that won't submit a form

I am trying to add a few "next" and "back" buttons to a form. The Idea is to divide the filling-out process into several steps and with these buttons, the div of the current step gets hidden and the next resp. previous step is displayed.
My Problem is that when I add buttons in the following way...
<button class="proceed_button" id="loan_information">Proceed</button>
<button class="cancel_button" id="loan_information">Cancel</button>
... they submit the form.
Is every button inside a form-tag considered to be a submit-button?
If so, how can I change this behavior?
If not, why are they doing it then?
Ok, the solution is that the button needs a type.
<button type="button" class="proceed_button" id="loan_information">Proceed</button>
<button type="button" class="cancel_button" id="loan_information">Cancel</button>
Like this, it won't submit the form anymore.
According to http://w3schools.com/html5/att_button_type.asp the default type is depending on the browser, so you should always specify the type.
I'm not sure that you want a button, maybe you want it to look like a button. Either way, refer to this post: rails 3: display link as button?
Once you have your button, you'll need to update your javascript to prevent anything from happening when it's clicked (assuming you have jquery). It's still nice to provide a real fallback for those dinosaurs without js, so assuming your proceed button submits for users without js, for those with js you'd do something like:
$('#proceed_button').click(function(e) { e.preventDefault(); // Show and hide your divs here });
Also note that in your posted code you should not have two buttons with the same id, your ids and classes look swapped.

facebook like button on my site only shows up after you refresh the page. does it have to do with all.js

I used code from
http://developers.facebook.com/docs/reference/plugins/like/
to add a like button on the site. I have the script tags right after the body as described and the div further down by my header, but when I load the page, the like button is not there. but if I hit refresh its there. my guess is that the all.js is taking too long to load and its missed somehow on the 1st load. on the 2nd refresh, I assume the js is cached and things work as expected.
any idea how to wait on this? I have tried putting the script in the head, at the bottom.
When you say "I have the script tags right after the body", do you mean outside of the body? If so, try putting it in side the body, but after all other element inside of the body.
<body> ...other code ...other code ...other code
<script>Put your script here</script>
</body>