Skip to content
Advertisement

Tag: html

Changing website favicon dynamically

I have a web application that’s branded according to the user that’s currently logged in. I’d like to change the favicon of the page to be the logo of the private label, but I’m unable to find any code or any examples of how to do this. Has anybody successfully done this before? I’m picturing having a dozen icons in

Invoking JavaScript code in an iframe from the parent page

Basically, I have an iframe embedded in a page and the iframe has some JavaScript routines I need to invoke from the parent page. Now the opposite is quite simple as you only need to call parent.functionName(), but unfortunately, I need exactly the opposite of that. Please note that my problem is not changing the source URL of the iframe,

How can I change an element’s class with JavaScript?

How can I change the class of an HTML element in response to an onclick or any other events using JavaScript? Answer Modern HTML5 Techniques for changing classes Modern browsers have added classList which provides methods to make it easier to manipulate classes without needing a library: Unfortunately, these do not work in Internet Explorer prior to v10, though there

How to change the href attribute for a hyperlink using jQuery

How can you change the href attribute (link target) for a hyperlink using jQuery? Answer Using will modify the href of all hyperlinks to point to Google. You probably want a somewhat more refined selector though. For instance, if you have a mix of link source (hyperlink) and link target (a.k.a. “anchor”) anchor tags: …Then you probably don’t want to

When should I use Inline vs. External Javascript?

I would like to know when I should include external scripts or write them inline with the html code, in terms of performance and ease of maintenance. What is the general practice for this? Real-world-scenario – I have several html pages that need client-side form validation. For this I use a jQuery plugin that I include on all these pages.

Highlight a word with jQuery

I basically need to highlight a particular word in a block of text. For example, pretend I wanted to highlight the word “dolor” in this text: How do I convert the above to something like this: Is this possible with jQuery? Edit: As Sebastian pointed out, this is quite possible without jQuery – but I was hoping there might be

How can I remove a child node in HTML using JavaScript?

Is there a function like document.getElementById(“FirstDiv”).clear()? Answer To answer the original question – there are various ways to do this, but the following would be the simplest. If you already have a handle to the child node that you want to remove, i.e. you have a JavaScript variable that holds a reference to it: Obviously, if you are not using

Advertisement