You see the stackoverflow.com inside of the red border? I know that it can be changed by HTML DOM but I don't know how.
No, it can't be changed. What you could do is is not create a link but instead have an element with style="cursor:pointer" with a click handler that navigator to another page. That's kind of evil though and breaks things like search engines and accessibility
Related
I have written a code for my html website project. When I open the html file itself, it loads correctly on various browsers. However, when I try to access the same file via localhost/xxxxx.html, the buttons don't seem to work. Other images and links work fine. All the files are placed within the same folder.
I have used a href along with the button element.
Can someone please help me? The project is due tomorrow and I am not a technology/coding native.
TIA!
The button element will not redirect you to the link you want because that's not what it is built for.
As you said, your link works fine, so you can use your link to navigate.
If you still want to use the button element, you can wrap it with the <form action="the_link_you_want_to_navigate" method="GET">. You can also use JavaScript code with a click event listener too.
But I think the best way to do this is by using the <a> tag and make it looks like a button using CSS properties.
Without seeing all your code it's tough to know why it's not working in your localhost. But... within the <button> element it's not typical to add an href the same way you would with an <a>. You can do it but with an onclick event in javascript.
I would suggest doing an Text and styling the .button class in your css.
Hopefully this helps and good luck on your project.
While I'm trying to switch between different sections of my webpage I am getting the following page as shown in the image. How can I solve this?
you need to provide context for your question for people being able to help you. I imagine you are trying to navigate between different html files, by clicking into an anchor tag, is that correct?
Go to next page
So in that case, you might be adding a wrong relative route, otherwise I think you should add more context to your question.
If you are trying to switch between sections on your webpage. Try adding section and giving them id. Then from any anchor tag you can reach the section by adding the following code.
Section 1
you can use jquery
$(".div").load("index.php .yoursection");
To switch between sections on your webpage,Use the id selector ,
Example:
<p id="opening">Hyperlinks are utilized by a web browser to move from one page to another...</p>
Now add the anchor tag to link,
Opening
"Opening" will be displayed as a link on the webpage. On clicking it, you will be switched on the same webpage where the id is "Opening".
In this example it is the paragraph tag.
If you trying to switch into another webpage,
Go to home page
If you check the websites which use commentpress for commenting (example: http://futureofthebook.org/commentpress/), you can see there is a link like:
2 comments on paragarph 1
and when you click on the link, it will show the comments for that paragraph, and if you click on the link again, the comments will hide.
How can I make those kind of link? I know if use something like:
Comment for whole article<br>
I will have a link, that if I click on it, it will take me to the another part of the page, but I want to have the same thing as I mentioned above.
I didn't find what you were referring to on that web site, but it sounds like you're describing some method of toggling visibility of an element. You can do that with either JavaScript or with CSS selectors; here's how to do it with CSS.
I just found that, in Adobe Dreamweaver CS3, this code segment seems fine in the design view,
Test Anchor
but if I add an "id" attribute to this "a" tag, like this,
<a id="test" href="#">Test Anchor</a>
there would be an icon at the left side of the "a" element, something just like an open book. (I have no privileges to upload image)
What is the meaning of the icon? Is there anything that Dreamweaver implies? I've tried to google some groups of keywords, and got nothing but ads.
Any help? Thanks a lot!
This icon (should look like a shield with an anchor on it) is a Dreamweaver design view indicator. This indicator is used to identify "named" anchors. No image that will be uploaded to your site, so don't worry about that. Anchor () tags with an ID are considered "named" as you can add a hash to the end of your URL to have the browser "jump" to the named/ided element. If you file is test.html and you visit your page with test.html#test then the browser will load up your page and "jump" to the named anchor. In recent browsers (not sure how far back, but likely far enough to not worry too much about it now) anchors with an id attribute value will work in the same manner as those with a name attribute value.
If you do not like this icon appearing when you have a couple of options:
Edit (Dreamweaver on Mac) -> Preferences, Invisible Elements, uncheck Named anchors.
Or View -> Visual Aids -> Invisible Elements. This option turns off all invisible element indicators listed in the preferences, so make sure you know what things your turning off.
It's probably just using the symbol to identify text on the page that's a link, save the file and load it up in your web browser, chances are the icon isn't actually part of your code.
I'm pretty sure that many people have thought of this, but for some reason I can't find it using Google and StackOverflow search.
I would like to make an invisible link (blacklisted by robots.txt) to a CGI or PHP page that will "trap" malicious bots and spiders. So far, I've tried:
Empty links in the body:
<a href='/trap'><!-- nothing --></a>
This works quite nicely most of the time, with two minor problems:
Problem: The link is part of the body of the document. Even though it is pretty much unclickable with a mouse, some visitors still inadvertently hit it while keyboard-navigating the site with Tab and Enter. Also, if they copy-paste the page into a word processor or e-mail software, for example, the trap link is copied along and sometimes even clickable (some software don't like empty <a> tags and copy the href as the contents of the tag).
Invisible blocks in the body:
<div style="display:none"><a href='/trap'><!-- nothing --></a></div>
This fixes the problem with keyboard navigation, at least in the browsers I tested. The link is effectively inaccessible from the normal display of the page, while still fully visible to most spider bots with their current level of intelligence.
Problem: The link is still part of the DOM. If the user copy-paste the contents of the page, it reappears.
Inside comment blocks:
<!-- <a href='/trap'>trap</a> -->
This effectively removes the link from the DOM of the page. Well, technically, the comment is still part of the DOM, but it achieves the desired effect that compliant user-agents won't generate the A element, so it is not an actual link.
Problem: Most spider bots nowadays are smart enough to parse (X)HTML and ignore comments. I've personally seen bots that use Internet Explorer COM/ActiveX objects to parse the (X)HTML and extract all links through XPath or Javascript. These types of bots are not tricked into following the trap hyperlink.
I was using method #3 until last night, when I was hit by a swarm of bots that seem to be really selective on which links they follow. Now I'm back to method #2, but I'm still looking for a more effective way.
Any suggestions, or another different solution that I missed?
Add it like you said:
<a id="trap" href='/trap'><!-- nothing --></a>
And then remove it with javascript/jQuery:
$('#trap').remove();
Spam bots won't execute the javascript and see the element, almost any browser will remove the element making it impossible to hit with tabbing to it
Edit: The easiest non-jQuery way would be:
<div id="trapParent"><a id="trap" href='/trap'><!-- nothing --></a></div>
And then remove it with javascript:
var parent = document.getElementById('trapParent');
var child = document.getElementById('trap');
parent.removeChild(child);
this solution seems to work well for me, luckily i have bookmarked it. I hope it helps you as well.
you can create a hidden link like this and put it at the very top left of your page and to prevent regular users from accessing it too easily you can use css to lay a logo image over this image.
<img src="images/pixel.gif" border="0" alt=" " width="1" height="1">
if you are interested in setting up how to blacklist the bots refer to this link for detailed explaination of howto.
http://www.webmasterworld.com/apache/3202976.htm