This question already has answers here:
How to make HTML open a hyperlink in another window or tab?
(9 answers)
Closed 8 years ago.
How do I transform the first section of this document.write code into a popup link? Note the first part says "<a href=\"\/popups\/fed_budget.asp\"><img src=\"http:\/images\/video_graphic.jpg\, etc. How do I change that button link (video_graphic.jpg) to a popup instead of taking me to a different page? This is what I currently have:
document.write("<td width=\"251px\"><a href=\"\/popups\/fed_budget.asp\"><img src=\"http:\/images\/video_graphic.jpg\" alt=\"Video Graphic\" \/><\/a><\/td>");
document.write("<td style=\"padding-top:30px; padding-left:10px; padding-right:10px\">");
document.write("<b class=\"blue_text\">Recent News<\/b><br \/><br \/>");
document.write("<strong><a href=\"\/news\/newshub\/articles\/federal_budget_2014.asp\">Your Federal Budget Update<\/a> <\/strong> <b class=\"blue_text\">New<\/b><br \/>");
document.write("Read our run-down on the super side of this year's Budget.<br \/><br \/><br \/>");
document.write("<strong><a href=\"\/news\/newshub\/articles\/EOFY_Tips_tricks.asp\">EOFY tips and tricks<\/a><\/strong> <b class=\"blue_text\">New<\/b><br \/>");
document.write("Six strategies to help you get your super in shape.<br \/><br \/>");
document.write("<\/td>");
document.write("<\/tr>");
document.write("<\/table>");
Popup link? Did you mean open it in a new tab ?
Just add attribute target="_blank" to the a tag.
Something like:
<a target="_blank" href="..."><img src="..." /></a>
Ps.: Avoid using document.write
target=“_blank” vs. target=“_new”
HTML <a> target Attribute
If opening the link in another window is what you mean by "popup," the simplest thing for you to do would be to add a target attribute to your link, so it looks like this:
<img src="http://images/video_graphic.jpg" alt="Video Graphic"/>
If, instead, you want to open this in a simplified new window, you'll have to use a JavaScript click handler that calls window.open:
...
Oh, and I'd parrot the whole "don't use document.write ever" philosophy.
Related
This question already has answers here:
window.open() add a rel="nofollow" attribute
(3 answers)
Closed 5 years ago.
I want to make the links in this javascript code nofollow. Please help me how to do that.
<img src="https://example.png/>
According to https://developer.mozilla.org/en-US/docs/Web/API/Window/open you can add a third parameter in the window.open method that is a comma separated string with name value pairs - but rel is not supported...
Seems like html may be a good option.
<a href="www.example.com" rel="nofollow" target="_blank" >Link</a>
If you need to do this from js you could trigger a click on the link.
This question already has answers here:
What is href=javascript:;
(8 answers)
Closed 5 years ago.
What is the purpose of javascript:; in the href attributes of the hyperlinks?
<div data-trigger="spinner" id="spinner">
<span id="spinner-value"></span>
<input type="hidden" value="1" data-spin="spinner" data-rule="quantity" data-max="10">
-
+
</div>
the attribute href="javascript:;" is used to remove the behavior from the link.
If you would use eg. href="", the webpage would reload when you click the link. But with href="javascript:;" nothing will happen.
Later a script adds an event handler that will be executed when clicking this link.
EDIT: You need a or button elements as they are the semantic representatives for clickable objects.
To prevent links from refreshing webpage/redirecting you once clicked.
the purpose of "javascript:;" have save meaning with "javascript:void(0)"
Read here : javascript void functions
This question already has answers here:
Landscape printing from HTML
(18 answers)
Closed 8 years ago.
I was trying to set the print orientation into landscape through javascript. I'm only just using the window.print() function for the page's content to be printed.
here's the code:
<a href="" onClick="window.print();return false">
<img src="images/print.png"></a>
With this I was able to print a sample page. But only it was on portrait format. The client requires it to be in landscape. so I tried on many codes I found. here's the one am sure your most familiar with.
<script type="text/javascript">
$("#printLandscape").on('click',function () {
$('head').append('<link href="printLandscape.css" title="printLandscape" rel="stylesheet" />');
});
</script>
since it wasn't a button that am using to call the print function but an image type with href, I tried to change the previous one with:
<a href="" onClick="window.print();return false" id="printLandscape">
<img src="images/print.png"></a>
See the id="printLandscape", I tried that on to be able to call the javascript function declared above and make the page print into my desired format which is landscape. But when I tried to print, to see if it was working. The printed page still has the default/formal or portrait type.
Is there something am missing? Or did I not declare the javascript properly especially the id on href for it not to work fine?
S.O.S
I think you should make the page property landscape in CSS:
#media print{#page {size: landscape}}
The support is left to the browser and it appears not to be supported in all browsers.
This question already has answers here:
change html text from link with jquery
(7 answers)
Closed 7 years ago.
I have the following html structure:
<div class="event tiny">
Something
</div>
And I want to replace the text of this link with "Anything" …
When doing this …
$('.event a').replaceWith("Anything");
… the text is replaced but also the link is gone.
When doing this …
$('.event a').text().replaceWith("Anything");
… nothing happens.
Like this, if the new text is all the same.
$('.event a').text("Anything");
jQuery loops over the a elements, and replaces its content with the "Anything" text.
These suggestions, for setting the inner text & URL link within a a href didn't work for me (using JQuery v1.8.3)
Here's what did work though:
HTML
<a id="hrefAnalysisName" ></a>
JavaScript
$("a#hrefAnalysisName").attr("href", "/SomePage/ShowAnalysisDetails.aspx");
$("a#hrefAnalysisName").text("Show analysis");
Hope this helps!
You could also change the link by href if it's related to the URL.
$('a[href="/whatever"]').text("Anything");
You are able to get this result the next ways result will be the same:
HTML
<div class="event tiny">
<a class="html" href="/whatever">Something</a></br>
<a class="text" href="/whatever">Something</a></br>
<a class="replaceWith" href="/whatever">Something</a>
</div>
JS
$('.event a.html').html('Anything-html')
$('.event a.text').text('Anything-text')
$('.event a.replaceWith').replaceWith('<a class="replaceWith" href="/whatever">Anything-replaceWith</a>')
<img title="<a href='#' onClick='alert('Hello World!')>The Link</a>" />
So I've got some specific question.. I already know that I can work with attributes inside a TITLE attribute.. But can I work with events inside a TITLE attribute?
(btw - It seems like a rubbish code, but this already works as is should on my web project - I just need a way to use some Javascript on this sheathed link.)
I USE Jquery framework.
No, this is, as you say "rubbish code". If it works as should, it is because browsers try to "read the writer's mind" - in other words, they have algorithms to try to make sense of "rubbish code", guess at the probable intent and internally change it into something that actually makes sense.
In other words, your code only works by accident, and probably not in all browsers.
Is this what you're trying to do?
<img title="The Link" />
When you click on the image you'll get the alert:
<img src="logo1.jpg" onClick='alert("Hello World!")'/>
if this is what you want.
Im my browser, this doesn't work at all. The tooltip field doesn't show a link, but <a href='#' onClick='alert('Hello World!')>The Link</a>.
I'm using FF 3.6.12.
You'll have to do this by hand with JS and CSS. Begin here
<img title="The Link" />
no, you can't do that, but you can use event handlers to change the title:
<img src="foo.jpg" onmouseover="this.title='it is now ' + new Date()" />