11

I have a page for member's where log in is essential. On this page members get links for lectures conducted. Lectures links get added regularly. And Links to recording are fetched on this page from database and last 30 recording links are available (through Limit $max). code is as follow -

<a class="fancybox fancybox.iframe more_info_btn" href="<?=$data\['recording_link'\]?>" >Play Recording </a>

Here, when user move cursor on "Play Recording" he can see recording link in left bottom corner of browser.

How can I hide this Link getting displayed in left bottom corner on mouseover ? Can i Show only Word "Recording" Instead of link displayed ?

9 Answers9

10

You just have to do the same as it was suggested with the button, but using the anchor you wanted. This is, use the onclick event instead of setting href attribute. And additionally you could add a noop js operation to href.

See this link: http://asp-arka.blogspot.com.uy/2014/08/hide-url-on-mouse-hover-of-hyper-link.html

<a class="fancybox etc etc etc" href="javascript:void(0)" onclick="window.location.href='<?php echo $data['recording_link'];?>'">Play Recording</a>
Sergio Robaudo
  • 101
  • 1
  • 6
4

You can use buttons instead of <a> for this purpose:

<button onclick="window.location.href='location.html'">Continue</button>

example for your case

<button class="class" onclick="window.location.href='<?php echo $data['recording_link'];?>'">Play Recording</button>
  • I tried it...it works perfect and not showing url in bottom.but class used for a is for opening page in fancybox, which is lost in button – Dr Manish Lataa-Manohar Joshi Mar 11 '14 at 20:55
  • can u help me ? code provided by u works perfect and not showing url in bottom.but class used for a is for opening page in fancybox, which function is lost in button. link gets opened in parent window and one can see link (which i want to keep hidden) in address bar. so my aim is not getting fulfilled... – Dr Manish Lataa-Manohar Joshi Mar 12 '14 at 04:04
  • Then probably you need to fix your JavaScript & jquery whatever you have used for it. –  Mar 12 '14 at 08:26
  • Give button an id and handle onclick event using javascript and execute the fancybox –  Mar 12 '14 at 08:29
4

This function convert all links to hiding hover links :

 $('a').each(function(){  
 $(this).attr('onclick','window.location.href="'+$(this).attr('href')+'"');
 $(this).attr('href','#');
 });
user2267379
  • 1,067
  • 2
  • 10
  • 20
3

Check the below code it will work in all browsers

Hide url toaster in bottom left on mouseover

$(function(){
           $("a").each(function (index, element){
               var href = $(this).attr("href");
               $(this).attr("hiddenhref", href);
               $(this).removeAttr("href");
           });
           $("a").click(function(){
               url = $(this).attr("hiddenhref");
              // window.open(url);
                                         window.location.href = url;
           })
       });
ul > li > a{
  font-size: 18px;
  line-height: 30px;
}

ul > li > a:hover {
  color: #425CD2;
  text-decoration: underline !important;
  cursor: pointer;
}
<ul>
 <li><a href="http://www.google.com">Google</a></li>
 <li><a href="https://codepen.io">Codepen</a></li>
 <li><a href="https://codepen.io/awesomeSri/pen/WBKwpz?editors=1111" >Codepen hide url toaster snippet</a></li>

</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
3
  1. <a onclick="location.href='www.youtube.com'">click</a> you should this it will not show any URL or message on the bottom corner.

  2. <a href="javascript:void(0)" onclick="location.href='https://www.youtube.com/></a> if you use javascript:void(0) then it wil shown javascript void(0) on right bottom corner in place of url.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

You can't override the browser. Just like you can't edit or remove what's shown in the address bar or bind a custom function to the back or forward buttons.

Mooseman
  • 18,763
  • 14
  • 70
  • 93
  • I do not want to hide link shown in address abr. I want to hide link shown in left bottom corner on mouseover – Dr Manish Lataa-Manohar Joshi Mar 11 '14 at 20:04
  • It's an analogy. Browsers are designed to respect the client's privacy and preferences above the preferences of the website. Besides, if somebody really wanted to see the link, they'd just open F12 Devtools. – Mooseman Mar 11 '14 at 20:05
  • (You may also want to check out http://stackoverflow.com/questions/8587809/change-link-mouseover-text-on-the-bottom-of-a-browser-window) – Mooseman Mar 11 '14 at 20:08
0

Here is a sort of hack to achieve this function
two efficient ways to go about this

1.

document.$('fancybox').addEventListener('click', function() { window.location.href = '<?$=data['recording_link']?>' } );

//non-jquery:

document.getElementsByClassName('fancybox')[0].addEventListener('click', function() { window.location.href = '<?=$data['recording_link']?>' } );

But as @Dr_J_Manish has already stated this doesn't work but will instead direct him to a nonsensical webpage address at '<?=$data['recording_link']?>' (Not a website address... DUH.)

2.

The second approach absolutely will work for @DR_J_Manish 's purpose: to activate a PHP function on a link click w/out the annoying overlay that appears when hovering a link.

To achieve this we will need to use a major workaround... This workaround could be considered a 'HACK':

1.

Make a new element and give it the ID 'Play-Recording':

<button id="Play-Recording" class="fancybox fancybox.iframe more_info_btn"> Play Recording </button>

2.

Make another new element which is exactly the same as @DR_J_Manish 's code above except for the class and other styling attributes.

<a id="GetClickedOn" href="<?=$data['recording_link']?>"> I'm Hidden! </a>

Make sure that this element is at the VERY BOTTOM of the Body tag or else there could be interference.

3.

Now make this element invisible and always off the screen...
Code so far should look like:

<body>
  <!--Put other stuff here or whatever-->

  <button id="Play-Recording" class="fancybox fancybox.iframe more_info_btn"> Play Recording </button>

  <!--Put some other stuff here...-->
  <!--End of other content other than hidden stuff...-->

  <a id="GetClickedOn" href="<?=$data['recording_link']?>" style="visibility: none; position: fixed; bottom: 3000%; width: 0; height: 0;"> I'm Hidden! </a>

  </body>

4.

Now for the fun part... Javascript... This part is pretty simple... add this code to the bottom of your page just after the <a href="">I'm hidden</a> tag we just made

<script>
  document.getElementById('Play-Recording').addEventListener('click', function() { document.getElementById('GetClickedOn').click() } );
</script>

5.

So your final code snippet should look like:

<body>
<!--Other Code-->

  <button id="Play-Recording" class="fancybox fancybox.iframe more_info_btn"> Play Recording </button>

<!--Some More Code-->

  <a id="GetClickedOn" href="<?=$data['recording_link']?>" style="visibility: none; position: fixed; bottom: 3000%; width: 0; height: 0;"> I'm Hidden! </a>

  <script>
    document.getElementById('Play-Recording').addEventListener('click', function() { document.getElementById('GetClickedOn').click() } );
  </script>

</body>

Now if you really want to be efficient then you could research how to do PHP commands in javascript... but I know thats not the easiest...

You could also transfer the code inside the script tag to a .js file and then link it like so --> <script src="path-to-my-js-file.js"></script>.



Here is a snippet to demonstrate what type of thing i'm going for...

var button1 = document.getElementById('click1');
var button2 = document.getElementById('click2');
button1.addEventListener('click', function() { button2.click() } );
<button id="click1">Click Me</button>
<br/><br/>
<span>And get the same result as&nbsp;</span><a id="click2" style="text-decoration: none;" href="https://example.com"><button><strong>Clicking Me</strong></button></a>
<br/>
<p>
Re-Run the code-snippet to see the code in use again in case you missed it...
<br/>
Notice how with the first button there isn't any href attribute or anchor tag (the 'a' tag).
</p>
255.tar.xz
  • 700
  • 7
  • 23
  • Hey I answered this and obviously it took a while, so if I could get some recognition for this good code that'd be great. (Clicking the accept answer box) I mean I already know for an exact fact that if your button worked before but had the thing in the corner then when you do this one it will work for certain. – 255.tar.xz Oct 23 '18 at 16:37
0
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<a class="fancybox etc etc etc" href="javascript:void(0)" onclick="window.location.href='<?php echo $data['recording_link'];?>'">Play Recording</a>

<script>
    document.querySelector('a').addEventListener('mouseover', function(){
        document.querySelector('a').style.display = 'none';
    });
</script>

</body>
</html>
PAPPU BABU
  • 17
  • 1
0

You can solve your problem with this one

const hideBottomUrl = ()=>{
    let anchor = document.getElementById('anchor');
    anchor.setAttribute("href","https://stackoverflow.com/");
    anchor.style.color = "black"; anchor.style.textDecoration = "none";
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a style="cursor: pointer;" onclick="hideBottomUrl()" id="anchor">Go your page</a>
    <a href="https://stackoverflow.com/">it will hover</a>
</body>
</html>