HREF links and javascript: Navigation

Posted by: Rick Strahls WebLog, on 02 Jan 2007 | View original

I seem this mistake  repeatedly: I have a hyperlink on a page and rather than execute another URL I want it to execute a small bit of JavaScript code. Something like click a button and hide another control on the page:   <a href="javascript:document.getElementById('DragPanel').style.display='none';">Click</a>   This might seem reasonable, but if you run this code youll quickly find out that this doesnt work. Well, the control hides alright but so does everything else...

Advertisement
The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.

Similar Posts

  • Recipe: Implementing Role Based Security with ASP.NET using Windows Authentication and SQL Server more
  • Designing the DotNetNuke Skinning Toolkit more
  • Taking a look at Nikhil's Script# more
  • More on URL Rebasing in Master Pages more
  • My Top 10 Cool Features Found in 3.2/4.0 more
  • IJavaScriptObject in the new version more
  • Enhancements to skmLinkButton more
  • Enhancements to skmLinkButton more
  • Enhancements to skmLinkButton more
  • Stopping JavaScript Errors When Opening a LinkButton in a New Window more

News Categories

.NET | ADO.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Community Server | dasBlog | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD