Hi, need a solution to do this: suppose there is a url more than 40 chars long, like: fakekedomain.com/index.php?a=abd&b=bcd&page=5&set=12&name=url I want to make it like this: fakedomain.com/index.php?...name=url or, can i completely hide it from showing in the status bar? how can i do it? waiting for suitable suggestion
Well, I suppose check length of string if it is more than 20 chars for example, then use substr PHP: to cut first 10 and last 10 chars from it.
<a href="your-long-url-etc-etc-etc-etc" onmouseover="window.status=this.href.substring(0,10);" onmouseout="window.status='';">Link text</a> Code (markup): This only truncates (to 10 characters in this case), you can work with the this.href value to get a nicer value. I don't recommend doing this though, besides seeming like a waste of time and effort, browsers have options to disable sites from working with the status bar, some even by default, such as Firefox.
I think you are confused. Php is a server side language and can not message with a browsers status bar. I suggest you look into a javascript solution to hiding the link from the status bar mouseover. if you want to shorten what is shown in <a href="">THiS PORTION</a> then that is different. <?php function sniphref($href) { if(strlen($href) >= 20) { $starthref = substr($href,0,10); $endhref = substr($href,0,-10); $href = $starthref."...".$endhref; } else { } return $href; } echo "<a href='http://forums.digitalpoint.com/showthread.php?t=404468'>".sniphref("'http://forums.digitalpoint.com/showthread.php?t=404468")."</a>"; ?> PHP: The above code has not been tested, but I think it works.
I redid it just a bit. Not much just the lengths are different. <?php function sniphref($href) { if(strlen($href) >= 30) { $starthref = substr($href,0,15); $endhref = substr($href,0,-10); $href = $starthref."...".$endhref; } else { } return $href; } echo "<a href='http://forums.digitalpoint.com/showthread.php?t=404468'>".sniphref("'http://forums.digitalpoint.com/showthread.php?t=404468")."</a>"; ?> PHP: Output http://forums.digi...p?t=404468 I don't know, play with it a bit to get the desired length to show.
I know it sounds redundant but I guess you can redo the function in this way too. function sniphref($href) { if(strlen($href) >= 30) { $href= substr($href,0,15)."...".substr($href,0,-10); } return $href; } PHP: