How can I stop window.status from displaying? - javascript

I have the following:
<a class="button accessLink"
id="loginLink"
href="#"
data-action="Login"
data-dialog="access"
data-disabled="false"
data-entity="n/a"
data-href="/MyAccount/Access/Login"
title="Login">Login</a>
and:
$('.accessLink')
.mouseover(function() {
window.status = '';
});
However when I mouseover the link above I still see
<my ip address>/#
Is there some other way I can stop this showing at the bottom of the browser window?

How about not using an anchor<a> tag altogether ?
Handle the click event of a <span> or a <div> element in jQuery and do a location.href to take the user to the link specified in element's data-href. That way, nothing would show up in status bar.

window.status would be disabled by default in most recent browsers. Consider the
scenario where a malicious website could effectively impersonate a trusted entity:
<script>
$('#bad-link').mouseover(function() {
window.status = 'www.microsoft.com';
});
</script>
Click me
Also remember that a lot of browsers by default don't even display the status bar anymore!

Please Try this:
specify href="javascript:"
<a class="button accessLink"
id="loginLink"
href="javascript:"
data-action="Login"
data-dialog="access"
data-disabled="false"
data-entity="n/a"
data-href="/MyAccount/Access/Login"
title="Login">Login</a>

Related

How to hide url on mouse hover of a hyper link

I'm my backend part of the app which is built in PHP Symfony I have HTML twig files, I want to change behavior for some href link, I want to hide URL in the bottom left corner after I hover them, I tried this solution that needs to change URL text to Contact, but it won't work
<a
class="activo"
href="link"
onmouseover="window.status='Contact'"
onmouseout="window.status=''"
>
Click
</a>
any help?
TL;DR; Simply use JavaScript, like:
window.location.href = "https://stackoverflow.com";
Remove the "<a ...>" element's href-attribute.
Then make it trigger a JavaScript function:
<a onclick="myFunction()">my link</a>
Finally, simply use JavaScript to redirect, like:
<script type="text/javascript">
function myFunction() {
window.location.href = "https://stackoverflow.com";
}
</script>
Note that you may need to add CSS to set cursor, I mean, already existing CSS may check href's existence, and not apply once href is removed.
Reusing same function
<a data-url="https://stackoverflow.com"
onclick="myFunction(this)">my link label</a>
<!-- In case you are using Twig or Blade: -->
<a data-url="{{ 'https://example.com' }}"
onclick="myFunction(this)">my other link</a>
<script type="text/javascript">
function myFunction(element) {
window.location.href = element.getAttribute('data-url');
}
</script>

a href=javascript:function() in firefox not working

I tried using a href=javascript:function() in a button, with a function to execute it. It works in Chrome but it doesn't work in Firefox.
Firefox doesn't alert and open blank tab.
Anyone can help me?
<script>
function verifyisbot() {
alert("test.");
var win = window.open("http://yahoo.com", '_blank');
win.focus();
}
</script>
Below is button code
<div class="frb_textcenter">
<a target="_blank" class="frb_button frb_round frb_center frb_fullwidth" href="Javascript:verifyisbot();">
click here
</a>
</div>
Update
I should have added that im using a live editor(profitbuilder) in wordpress to generate the page and button. There is no area for me to insert additional javascript onclick function to the button. So i figure out to use "ahref" blank field in the live editor to input javascript call function to fire up the function.
Is there any way i can make this work through the ahref without using onclick event? Or can i specify onclick function in the ahref field?
Sorry the test() is actually verifybot() function, typo mistake
You can achieve the goal using only the href attribute:
<a href="javascript:void(verifyisbot())" class="frb_button frb_round frb_center frb_fullwidth">
click here
</a>
It works, because when a browser follows a javascript: URI, it evaluates the code in the URI and then replaces the contents of the page with the returned value, unless the returned value is undefined. The void operator can be used to return undefined.
Use onclick event instead of a href=javascript.It works on firefox.See below:
<div class="frb_textcenter">
<a target="_blank" class="frb_button frb_round frb_center frb_fullwidth" onclick="test()">click here</a></div>
<script>
function test() {
alert("test.");
var win = window.open("http://yahoo.com", '_blank');
win.focus();
}
</script>
UPDATE 1: You can do it without use javascript.You just add the link in the href attribute.See below:
<a target="_blank" class="frb_button frb_round frb_center frb_fullwidth" href="http://yahoo.com">click here</a></div>
Give serious consideration to separating your JavaScript and your HTML such that the problem goes away. For instance, add an ID to your anchor and add an event handler through script:
<div class="frb_textcenter">
<a id="verify" target="_blank" class="frb_button frb_round frb_center frb_fullwidth" href="http://yahoo.com">
click here
</a>
</div>
Later...
<script>
function test() {
alert("test.");
var win = window.open("http://yahoo.com", '_blank');
win.focus();
}
window.onload = function () {
document.getElementById('verify').addEventListener('click', test);
};
</script>
Do note that with the example provided, you don't actually need JavaScript at all. The HTML itself will cause a new window/tab to open with Yahoo! loaded...

my page always redirects me to my server

I'm trying to make a redirection to other page (for example google) but it doesn't work. This is the code:
function algo(a) {
$.get("links/privado/verlink.php?" + a, function(data, status) {
document.getElementById("algunacosa").href = data;
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="algunacosa">Ir al link</a>
<button onclick="algo">Retrive link</button>
if the response is: http://google.com it redirects me to http://mrvikxd.ddns.net/m/http://google.com and appears an 403 error
Edit: I've seen the code on the Google Chrome development console and the href of <a id="algunacosa"> is href="http://google.com". I don't know why it doesn't go to Google.
Using the rel attribute on your anchor tag, you should be able to force the link to lead to an external site. https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types
<a id="algunacosa" rel="external">Ir al link</a>
Just fixed. verlink.php was in UTF-8 BOM and it was producing the \uffef character what is not visible but enought to confuse the browser

Unable to Simulate Click using JQuery

I have a link for downloading Audio Files. I wish to keep it hidden and allow the user to call it using a button. But somehow I am unable to trigger the click event.
Here is HTML:
<a class="APopupDown" data-icon="home" id="DownloadFile" href="http://yahoo.com/abc.mp3" download="My File Name">Download File</a>
<button data-icon="home" href="#" onclick="DlMsg()">Download</button>
And here is the trigger.
function DlMsg()
{
alert("I am here");
$('#DownloadFile').trigger('click');
}
A Jfiddle example is here
As you can see the diredct link works but the button doesn't. Any idea what I am doing wrong?
Thanks
----- UPDATE -------
I have made the change as per Jai's suggestion. However, it now starts playing the Audio instead of downloading, whereas what I want is to use HTML5's download functionality. Here is the jsfiddle link
Got the answer. Just see this fiddle http://jsfiddle.net/EWQ6n/512/
Source:
<a class="APopupDown" class="test" data-icon="home" id="DownloadFile" href="http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3" download="My File Name">Download File</a>
<button data-icon="home" id="btnDownload">Download</button>
Script:
$("#btnDownload").click(function(e){
$("#DownloadFile").get(0).click();
});
I just used like this
$("#DownloadFile").get(0).click();
to trigger the anchor click event.
You need to have a click event bound to that element first:
$('#DownloadFile').click(function(e){
e.preventDefault();
window.location.href = this.href;
});
then your trigger will work:
$('#DownloadFile').trigger('click');
Demo # Fiddle 506

Scrapy parsing of the hidden information appearing after link click

I try to parse some hidden information:
<a id="showInfoBtn" rel="nofollow" title="SomeTitle" href="some_link/some_hash"
onclick="return showInfo(event)">Info showed here after click</a>
When I manually click to this link, only get request to http://www.google-analytics.com appears at the firebug. And page not reloaded - only info showed as a link text.
How can I get info by scrapy?
I did not understand very well if what you're trying to get is to show some info inside the a tag or in other part of the page. But in any of the cases that will also depend on what does the showInfo() function return.
If the first case is what you need and showInfo() returns the text with the info, i believe this is what you're looking for:
<a id="showInfoBtn" rel="nofollow" title="SomeTitle" href="#" onclick="this.innerHTML=showInfo(event)">
Info showed here after click
</a>
Here's a demo with the example http://jsfiddle.net/P49Dv/ ;)

Categories