Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Help needed to understand the source code...
I visited the website bseindia.com some time ago and when i was checking for its coding i couldn't understand the action performed when you click on the buttons aligned horizontally at the top (About BSE, Markets, etc). The anchor have href attribute with value only "#". I could use something like that in my upcoming project so i would appreciate some help.
please tell the use of empty "#" in anchor tags href does and if any other language like Server-side etc then please do tell me.
This is a common practice. Actually these kind of links are used more like "buttons". I mean, the url will not change, but some action will happen, based on the javascript implementation.
Please read this post, to learn more: Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
please tell the use of empty "#" in anchor tags
It is a relative URL to the top of the current page.
If anything else happens when the link is clicked, it is because client-side JavaScript is involved.
Binding JS to links to the top of the page is a common practise, but a poor one. It is neither Progressive nor Unobtrusive.
The # is to keep the styling of the link (I think that is what it is for, not sure). An action takes place because javascript registers event handlers on the link, such as this:
html:
test
javascript:
document.getElementById('test').onclick=function(){
alert('you clicked it!');
}
here is a jsfiddle: http://jsfiddle.net/fZ2JQ/
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I wanted to click on an image, which will call a javascript function. The function is intended to change from one page to another web page on the same site. I don't want to open() a new page, but an existing page within the current site.
I tried using an anchor tag, with the href targetting the url of the destination. But I dont want an anchor, I want to use a clickable image.
I also tried the window.open() method but ended up with lots of opened windows!
I then tried donuts "window.location.replace(newUrl);" which worked instantly. How do I vote-up donuts advice from pure time ago? Can't see no up-arrow to the left of the post?
You don't need JavaScript to make a button or image into a link.
For an image, as others have pointed out in the comments, just do
<img src="...">
For a button, see How to create an HTML button that acts like a link.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Tried to get links to all issues of a publication for a given year, from this link: http://www.vetsci.org/journal/list.html?pn=vol&year=2018.
E.g: "Jan. Vol. 19 No.1. 1~160", which has an 'onclick' event.
edited
I would appreciate any help with how to do the following:
first, activate the onclick event;
second, get the link of the page to which the onclick event is leading the browser -> I have used the developer tools after clicking, to see the link of the new page. However, since this is no different to manually clicking and copy/pasting the url, I would like to know if there is a way to automatically read these links.
edited
Hope I am not spamming, since there are a couple of other threads on issues with getting popups and similar, but those seem like somewhat advanced stuff - at least from where I am standing :)
If you want to activate the event itself in any situation, you'll need something like Selenium. If you want to retrieve the page in the example you gave, inspection of the code shows that the onClick event loads the list.html page with parameters like so:
http://www.vetsci.org/journal/list.html?s_v={volume}&s_n={number}&sort=start_Page*1&TG=&pn=vol&year=2018&sm={4th argument}
I can't quite tell what the 4th argument is supposed to be because it's blank in all the examples you gave. If you do a GET request on that URL, you can use something like BeautifulSoup to parse the page.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So I've seen a mouse-hover effect on 2 websites so far and I really like it.
This is the effect I'm talking about.
I'd be grateful if somebody can tell me how to get that effect on my webpage.
It only appears under your cursor when you hover over the page.
The site you have linked in the comments uses the HTML canvas element. But You can simply use already existing libraries for that effect.
Examples mentioned in the comments:
http://jnicol.github.io/particleground/
http://github.com/VincentGarreau/particles.js
Simply, Go to the webpage you wanted to Copy it's effects or anything from it
Right click, View page source
If the effect is made by Css, you will find it in stylesheets tab
If it's using jQuery/Js, Search the head for <script> , Read them and copy the effect (assuming that you understand js/jquery
For more simplicity, use Firebug, open it and just point the cursor at the item you want to see it's source.
But, actually
You can find it at github Here
Change what you want.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
well, I just downloaded a code from internet and it has
login
when i click on it, it shows a pop up.
I want to use that pop on any other button , but does no know how to do that. can any one please explain me how it can be done or how the current given line is working.
I am just new to this, so please dont be mad if it is a stupid question.
Thank you
javascript:void(0) returns undefined, so the link does not actually lead to anywhere when clicked and the normal <a> element behavior is suppressed. That means there's a click handler set up on the element that handles showing the popup. This click handler is found somewhere else in the code.
I'm assuming that the click handler is associated with the action class, so if you attached class="action" to another element, you'll probably see the popup.
To create "pop ups" (actually known as alerts), you use the following code:
alert(yourStringMessageHere);
The javascript: part of the code you are showing simply tells the HTML parser that when the hyperlink is clicked, the following JavaScript should be executed. void(0) is asking for the expression 0 to be evaluated and since 0 is another way of expressing false, the expression essentially winds up causing nothing to happen, which when added to a hyperlink's href attribute is sometimes desirable. This code does not cause a pop up to appear. If you are getting one, it is because of something else.
Lastly, including JavaScript into html in this way is strongly discouraged as it is bad form and can lead to code that is difficult to read and maintain. JavaScript should be separated from HTML.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm (trying) to build an app based on boostrap/javascript/ and a nosql DB
a sort of small CRM/invoicing system
i need to show/hide button based on variable
for example for a quote, status could be "open", "lost" "win"
so on my quote details page when status of quote is open i want to show button
- win (who change status of quote id in db to win and copy quote to an order)
- lost (who change status of quote id in db)
but i want to hide button "Re-open" who change a cancel status to open
and so on for my different status..
so want i'm looking for is a way to collapse/hide some button depending of the status of my quote (i put the status of my quote in a variable called quoteStatus)
any suggestion will be welcome
thanks
jeebee
You can do something like that
if (quoteStatus==="value"){
document.getElementById("buttonId").style.display='none';
}
else{
document.getElementById("button").style.display='block';
}
this is just javascript, you could use jquery it will make it easier for you, so your code may look like that
if (quoteStatus==="value"){
$("#buttonId").hide();
}
else{
$("#buttonId").show();
}
To get more positive reactions to your question you have to show some research effort. This question is not useful in that mather that you havent actually showed us what you have tried, and the purpose of your functionality have possibly been asked and explained before? How to hide/show div based on variable using javascript. A div and a button is both elements.
Either way, as for your question, we need to know what you already have. The task in itself have several ways to be accomplished, and based on your existing code there could be a way to complete this task in a more correct manner than others.