Posts

Showing posts with the label Href

Anchor Jumping By Using Javascript

Answer : You can get the coordinate of the target element and set the scroll position to it. But this is so complicated. Here is a lazier way to do that: function jump(h){ var url = location.href; //Save down the URL without hash. location.href = "#"+h; //Go to the target element. history.replaceState(null,null,url); //Don't like hashes. Changing it back. } This uses replaceState to manipulate the url. If you also want support for IE, then you will have to do it the complicated way: function jump(h){ var top = document.getElementById(h).offsetTop; //Getting Y of target element window.scrollTo(0, top); //Go there directly or some transition }​ Demo: http://jsfiddle.net/DerekL/rEpPA/ Another one w/ transition: http://jsfiddle.net/DerekL/x3edvp4t/ You can also use .scrollIntoView : document.getElementById(h).scrollIntoView(); //Even IE6 supports this (Well I lied. It's not ...

Angular 2 Router No Base Href Set

Image
Answer : https://angular.io/docs/ts/latest/guide/router.html Add the base element just after the <head> tag. If the app folder is the application root, as it is for our application, set the href value exactly as shown here. The <base href="/"> tells the Angular router what is the static part of the URL. The router then only modifies the remaining part of the URL. <head> <base href="/"> ... </head> Alternatively add >= Angular2 RC.6 import {APP_BASE_HREF} from '@angular/common'; @NgModule({ declarations: [AppComponent], imports: [routing /* or RouterModule */], providers: [{provide: APP_BASE_HREF, useValue : '/' }] ]); in your bootstrap. In older versions the imports had to be like < Angular2 RC.6 import {APP_BASE_HREF} from '@angular/common'; bootstrap(AppComponent, [ ROUTER_PROVIDERS, {provide: APP_BASE_HREF, useValue : '/' }); ]); < RC.0 ...

Add Php Variable Inside Echo Statement As Href Link Address?

Answer : Try like HTML in PHP : echo "<a href='".$link_address."'>Link</a>"; Or even you can try like echo "<a href='$link_address'>Link</a>"; Or you can use PHP in HTML like PHP in HTML : <a href="<?php echo $link_address;?>"> Link </a> you can either use echo '<a href="'.$link_address.'">Link</a>'; or echo "<a href=\"$link_address\">Link</a>'; if you use double quotes you can insert the variable into the string and it will be parsed. Basically like this, <?php $link = ""; // Link goes here! print "<a href="'.$link.'">Link</a>"; ?>