creating javascript bookmarklet [duplicate] - javascript

This question already has answers here:
What do querySelectorAll and getElementsBy* methods return?
(12 answers)
Closed 6 years ago.
I need a javascript bookmarklet that will click on a button within a web based program I use for work. It is just the refresh button for part of the page. The element information (from Google Chrome's developer tools) is listed below.
Refresh
I tried this:
javascript:document.getElementsByClassName("Ref btn btn3d TableBtn").click();
Seems to do nothing.
I haven't messed with bookmarklets or javascript in a very long time, but I know something like this is possible.

You're getting an array returned to you. Trying to click on it is failing because even if there is only one matched element, you still aren't running your click function on it. You need to run your click function on that specific element by picking it from he returned array.
var button = document.getElementsByClassName("Ref btn btn3d TableBtn")
button[0].click()
The exact syntax you would use in your bookmarklet would be;
javascript:var button = document.getElementsByClassName("Ref btn btn3d TableBtn"); button[0].click();

Related

How do I click on a link that is 1000px down without the action taking me at the beginning of the page? [duplicate]

This question already has answers here:
How to prevent a click on a '#' link from jumping to top of page?
(24 answers)
Closed 7 months ago.
I'm currently working on a Cooking Recipe sharing website and there's a matter on my Likes/Dislikes system.
The matter is when I click on the link "LIKEđź‘Ť" as you can see in this picture, the page don't stay on the same position, it directly taking me at the beginning of the page, if you have some JS code to share with me in the purpose to solve my problem, please share.
I hope you understand my point, this matter can be resolved in JS but, I'm not a JS developer
it is complicated to solve the problem when you don't provide any code example.
However, this can be triggered from an anchor: ">
which moves you to the element having id="".
Or check the event function when you click on the like button.

How to use javascript to show the list of a datalist? [duplicate]

This question already has answers here:
Programmatically make datalist of input[type=url] appear with JavaScript
(2 answers)
Closed 2 years ago.
I have a datalist. Its list is empty at the beginning. I use javascript to append the options to that list and want to show the list immediately without clicking it manually. I may need to use javascript code to implement this. Could anyone know how to do this? Thanks in advance! By the way, document.getElementById("element").focus(); This doesn't work. It can only move the mouse to the input area but can't show the list. I want to show that list.
We need to create the "append the options to that list" function.
I think we can create that function based on the behavior of the click, and then run it after the page loads.

prevent bots to click on clickable images in javascript [duplicate]

This question already has answers here:
Check if event is triggered by a human
(9 answers)
Closed 4 years ago.
I have some images that are clickable. for each click , users can get some point.
But I want to prevent clicks that do by bots. in fact I want a way to detect that a real user is clicked or a bot.
I want do that in javascript or jquery. if anyone know a plugin that can do that Please introduce me to it.
You can simply assume it’s human, provided access to the page is protected by reCAPTCHA, and subsequent requests carry a CSRF token.

How to switch one page to another page using js? [duplicate]

This question already has answers here:
Is there a way to get a <button> element to link to a location without wrapping it in an <a href ... tag?
(10 answers)
Closed 5 years ago.
I want to know that how i call/switch one page to another page using javascript.
I am trying to creating a Game.
in which 2 slides.
First Slides is for game overview in which there is a
when i click on play button it should redirect me to second page.
i want to know how it will work in JavaScript.Can't use html.
Here is my game link which i want to create.
https://www.screencast.com/t/qmbzE9nWei2c
Please watch this link and understand how it work and help me give me some tips.
Thanks
You can do this by simply adding an onclick event to the button:
<button onclick="location.href='www.example.com';"> Play </button>

Link without tracking source web page [duplicate]

This question already has answers here:
Remove http referer
(10 answers)
Hide Referrer on click
(8 answers)
Is it possible to remove the referrer in PHP before redirected?
(5 answers)
Closed 5 years ago.
I am working on a web with php (laravel 5.4) and I have to generate several links that the user clicking on them does not let you know that the click originated from my web page. The idea is that it seems that the user wrote the link directly in the browser, and that does not relate in any way that clicked from my website. how can I do it? Thanks for your help.
You can do that using javaScript. You need to define a function that accepts a url as parameter and calls the javascript window.open().
Make a regular tag and in its href attribute pass javascript:void(0); so that the default link click action is stopped.
Now define an attribute onClick and call your defined function here and pass the url you want to open.
Please see the example below:
<script type="text/javascript">
function openURL(url)
{
window.open(url);
}
</script>
GOOGLE

Categories