I have a list of users displayed in the table and each users has link which is displayed and can be navigated to.
<div class="inline-icon-text">
<small class="text-muted d-md-none mr-3">Link</small>
<a [attr.href]="candidate.url" target="_blank" [title]="candidate.url">
<i class="material-icons">open_in_new</i>
</a>
</div>
Problem is, when I inspect link element it points to correct address but after clicking on it gets appended to app base url.
<a _ngcontent-c15="" target="_blank" href="www.test.sk" title="www.test.sk">...</a>
And after click it gets opened in the new tab with address localhost:4200/www.test.sk
What do I miss?
Always prepend your absolute external links with protocol or // shortcut for http:// OR https:// depending on your app's protocol.
<div class="inline-icon-text">
<small class="text-muted d-md-none mr-3">Link</small>
<a [attr.href]="'//' + candidate.url" target="_blank" [title]="candidate.url">
<i class="material-icons">open_in_new</i>
</a>
</div>
Browsers treat URLs as relative by default to facilitate in-app navigation.
As a side note, this behavior is not Angular-specific; other frameworks and plain sites behave exactly the same
Related
I'm learning HTML.
I've following code piece:
<a href="#B" id="specialClass" class="primary-btn icon-cart" data-one="#A" data-five="google.com" data-ten="#C" target="_blank">
<span id="pressButton">New Button</span>
</a>
When I press button based on slider and data-five gets triggered, I for some reason open in a new tab mywebsite.com/google.com instead of google.com.
What am I doing wrong?
If it is an address outside your web page you have to put the full path with https://google.es
<a target="_blank" href="https://google.es">Google</a>
Using link for open another page outside of project
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" href="https://www.google.kz/">
Web Page
</a>
</div>
but when click to link, opened this page: http://localhost:4200/google.kz - local page, not "google.kz"
How to make, open google.kz outsite link, not trying to find in local page?
You can use target="blank" as follows.
<a class="h3" href="https://www.google.kz/" target="_blank">
target
Where to display the linked URL, as the name for a browsing context (a tab, window, or iframe).
_blank: usually a new tab, but users can configure browsers to open a new window instead.
It should work the way you've described it, but another way of doing it is using the document.location api.
Example:
<div class="info-line">
<mat-icon class="s-20 ml-2">
language
</mat-icon>
<a class="h3" (click)="navigate()">
Web Page
</a>
</div>
inside your component:
navigate(){
document.location = "https://www.google.kz/"
}
below are two links with download attribute.
clicking on both gives different result, why?
<a href="https://www.w3schools.com/images/myw3schoolsimage.jpg" download>
dnld
</a>
<br>
<a href="https://scontent.xx.fbcdn.net/v/t45.1600-4/28204217_6081249221877_6688541583534456832_n.png?oh=9262305ce4d55f669767f01c1be364b1&oe=5B06C1A9" download >Download</a>
w3schools link downloads the image where as the other one simply opens the image.
because the extension should be displayed at end of url
<a href="https://www.w3schools.com/images/myw3schoolsimage.jpg" download>
dnld
</a>
<br>
<a href="https://scontent.xx.fbcdn.net/v/t45.1600-4/28204217_6081249221877_6688541583534456832_n.png" download >Download</a>
I'm trying to figure out how to get a tag on my page so when I click it, it jumps to another section on the same page.
I have a link in my show page with:
<li class="col-xs-4 col-sm-2 nopadding menuitem" style="background:#39AFBF">
<a href="#stats" class="hvr-sweep-to-bottom">
<span>impact</span></a>
</li>
I then have a section lower down on the same page:
<section class="counter index section parallax-bg" id="stats" data-background="<%= image_path 'testimonial.jpg' %>">
But when I save this, I get an error that says:
Couldn't find Profile with 'id'=stats
The same is problem arises with this one:
<li class="col-xs-4 col-sm-2 nopadding menuitem" style="background:#009CB2">
<a href="#feedback" class="hvr-sweep-to-bottom">
<span>feedback</span></a>
</li>
<section class="section index parallax-bg testimonial" id="feedback" data-background="<%= image_path 'webre.png', :style=>"background-repeat: repeat !important; background-size: inherit !important;" %>">
What you're using is an anchor link, and when anchors links are clicked, the browser is supposed to simply jump to the anchor in the currently loaded page.
However, in your case, it seems to be calling the URI /profile/:id with :id set to stats.
Are you sure that the href is correctly set to #stats, and not simply stats, because if it's set to the latter, then the link will point to /profile/stats (clicking on this will cause a request to be sent to server), instead of /profile/SOME_ID#stats (which will not cause a request; the browser will jump to anchor on current page). The latter is what should be happening, but it isn't. Hope this helps. :-)
I'm trying to parse a html code for specific content, but the problem I'm running into is that certain websites require you to click a "Show more" button.
When I grab the URL there's no way to tell it I want the full code with the "Show more" button clicked. Is there a way to grab the full source code of the page, because it keeps getting cut off after a point.
Example website: https://play.google.com/store/search?q=fm%20radio&c=apps&hl=en
The source code gets cut off at the "Radio hungary" app, which is the last app that loads automatically.
This even happens when I load everything and then try to view the pages source code.
It ends in:
style="display:none"> Show More </button> <div class="bottom-loading" style="display:none"></div> <div class="footer"> <div class="footer-links-container"> <span class="copyright"> ©2016 Google</span> <a class="footer-link id-no-nav" href="https://play.google.com/intl/en_us/about/play-terms.html" target="_blank"> Site Terms of Service</a> <a class="footer-link id-no-nav" href="http://www.google.com/intl/en_us/policies/privacy/" target="_blank"> Privacy Policy</a> <a class="footer-link id-no-nav" href="http://developer.android.com/index.html" target="_blank"> Developers</a> <a class="footer-link id-no-nav" href="https://play.google.com/artists" target="_blank"> Artists</a> <a class="footer-link id-no-nav" href="https://support.google.com/googleplay/?p=about_play" target="_blank"> About Google</a> </div> </div> </div></div><div class="loading" jscontroller="EgJAl" jsaction="rcuQ6b:rcuQ6b" id="page-load-indicator"></div><div id="instrument-manager-parent"></div><script src="https://wallet.google.com/inapp/lib/buy.js"></script><script
Even if I click the show more button.
The purpose of this is to grab all the URL's of the images, and I can't do this by hand because well.. we have thousands of images.
I believe if you just take advantage of the Javascript HTML DOM methods you can accomplish what you want to achieve.
This will help: http://www.w3schools.com/js/js_htmldom_methods.asp
By using this, you can target specific elements/ids/classes and pull or modify the information you want.
Jquery will also help you a lot with this.
You can solve it using Javascript dom,steps to do are
keep your content in a div element
set its default height as a fixed value
on clicking the show more link execute a javascript function to make the div element height to auto
in this way you can show content excerpt with javascript
If you go for server side, you can create a new page for showing the content.