Vue JS : Href link is not the same as data - javascript

I have this <a> href below that if clicked will redirect me to
the page.publicWebsite value is www.duckduckgo.com
{{page.publicWebsite}} displays www.duckduckgo.com
HTML show www.duckduckgo.com in the href so everything good ?
But when I click on the link I go to https://mywebsite/currentpage/www.duckduckgo.com
<a v-if="page.publicWebsite" target="_blank" :href="page.publicWebsite" :title="page.publicWebsite">{{page.publicWebsite}}<img src='/img/layout/icon-www.png' class='userInfoIcons' /></a>

That's because href treats your URL as a relative URL.
You've got to declare it as an absolute URL, one of two ways:
page.publicWebsite = 'https://www.duckduckgo.com'
// or
page.publicWebsite = '//www.duckduckgo.com'

Related

use javascript,php, or html to reload a page when the URL changes

I am trying to get a page that when the URL changes it immediately reloads and uses the parameters in the URL.
The first url is : http://localhost/victorphp/Callvisor/bp/index.php
This does not work for some reason:
<a href="http://localhost/victorphp/Callvisor/bp/index.php?section=user&Mpage=tools" onClick="window.location.reload" >
Test
</a>
When I click on the link the page reloads without the parameters.
Try to add id to your link
<a href="http://localhost/victorphp/Callvisor/bp/index.php?section=user&Mpage=tools" id="1" onClick="loadUrl(this)" >
Test
</a>
Create function loadUrl() in your js file
function loadUrl(lid){
var url=document.getElementById(lid.id).href;
location.href=url;
}

How to set the first part of a url to a JavaScript variable in a HTML a link

I've got a variable that gets the server url of the user:
var server = parent.Xrm.Page.content.getClientUrl;
I want to use that variable to be the first part of a html link and add the page name to the end of it to generate links for different pages. For example for the home page I need the a href to be a combination of var server and /homepage. I tried the following:
<a href="" onclick="this.href = 'server'+'/homepage" target="_blank">
But this didn't work. Any solution would be appreciated!
You can write an onclick method which will be implemented in javascript. There you will get the variable.
HTML:
<a href="" onclick="getUrl()" >
JS:
getUrl(){
window.open(server +'/homepage, '_blank');
}
or you can send the extra string from html as parameter
<a href="" onclick="getUrl('/homepage')">
-
getUrl(url){
window.open(server + url, '_blank')
}

href # is not appending to end of URL

href # is not appending to end of URL
I have written the html page on which one of the anchor tag has href "#". Whenever I am clicking on it, # is not appending at the end of URL path in browser. Same functionality is working in different websites. Please suggest..
<li class="nav-item d-md-down-none">
<a class="nav-link" href="#">
<i class="icon-location-pin"></i>
</a>
</li>
My current url is "http://localhost:8080/add/AddDocument.html"
After clicking on the link i should get "http://localhost:8080/add/AddDocument.html#"
But i am getting this "http://localhost:8080/add/#"
This issue is solved.
There is <base href=”/”> tag present in my html which was loading alternative html link while clicking on href="#".
Thanks for all your help.
Usually, it is to link to part of a page ('#about'). If it is just there instead of being empty('#' vs. ''), it prevents the page from being reloaded on click.
Normally, you define it like this:
<div id="about"></a>
In order for your href to have a clickable link ie a web address, by placing the hashtag symbol, you refer the element (image,text, video etc) as a href if the website link is either not yet available or if it’s in the same page you can use the hashtag followed by the id name.
Also please check your routing.

ng-href not responding other than updating link or addressbar when i clieck on it (Angular Js)

I've ng-href which replace values in href that will be ok but when i click on the link, It change url on address bar which is working correct to but doesn't process to execute that URL.
What's blocking url to process? I've taken off ng-click method off from the link as well.
<li id="tst_productList_categoryLeftNav_categoryFacet_{{categoryFacet.categoryId}}" ng-repeat="categoryFacet in vm.products.categoryFacets | orderBy : 'shortDescription'"
ng-class="{'f-selected' : categoryFacet.selected}">
<a href="javascript:;" ng-href="/search?categoryId={{categoryFacet.categoryId}}&filters={{vm.filters}}&sortby={{vm.sortBy}}&page={{vm.page}}&pageSize={{vm.pageSize}}&criteria={{vm.criteria}}&view={{vm.view}}&columns={{vm.columns}}">
<span class="f-name">{{categoryFacet.shortDescription}}</span>
<span class="f-count">({{categoryFacet.count}})</span>
</a>
</li>
what's blocking link?
ng-href directive internally creates href attribute. Try removing the href attribute that you have added manually.
Try to add target="_self"
to <a> element
<a target="_self" ng-href="/search?categoryId={{categoryFacet.categoryId}}&filters={{vm.filters}}&sortby={{vm.sortBy}}&page={{vm.page}}&pageSize={{vm.pageSize}}&criteria={{vm.criteria}}&view={{vm.view}}&columns={{vm.columns}}">

Test hyperlinks to see if links are going current page vs different page with jQuery / javascript?

Is there a way of using javascript/jquery to test if a clicked hyperlink is going to the current page (ie anchor tags) vs going to a different page.
If my current url page is http://www.mypage.com/mypage/index.html
If so, I want to ignore these instances:
<a href="#">
<a href="index.html#anchor5">
<a href="#mytitle1">
<a href="//www.mypage.com/mypage/index.html#anchor1">
<a href="mailto:xxxxxxxx#gmail.com>
<a href="tel:+12344555">
And also ignore other instances that I might have missed above that references the current page with a href tag.
Thanks

Categories

Resources