Javascript anchor prevent default href instead of using href="javascript:void(0);">
https://stackoverflow.com/questions/26014820/angularjs-binds-unsafejavascriptvoid0-when-value-is-javasciptvoid0
NOTE: use href="#" or href="" will still cause route to reload
use ng-click on a and pass $event to your function.
<a href="#" ng-click="yourFunction($event);">Click</a>
In your function do the following
$scope.yourFunction = function(e) {
e.preventDefault();
};
Javascript form open a new window
https://stackoverflow.com/questions/178964/after-submitting-a-post-form-open-a-new-window-showing-the-result
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "test.jsp");
// setting form target to a window named 'formresult'
form.setAttribute("target", "formresult");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "id");
hiddenField.setAttribute("value", "bob");
form.appendChild(hiddenField);
document.body.appendChild(form);
// creating the 'formresult' window with custom features prior to submitting the form
window.open('test.html', 'formresult', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
form.submit();
Angular anchor : <a
href="#"
class="more-info"
(click)="onClicked($event)"
>{</a>
public clickWindow = null;
onClicked($event) {// prevent href behaviour$event.preventDefault();// use form method above for new window for form submission
// for predefined url
// its important to have 'window' as target so same window is opened once this.clickWindow = window.open(url, 'window');
}
No comments:
Post a Comment