Skip to content
Advertisement

Tag: html

How to load up CSS files using Javascript?

Is it possible to import css stylesheets into a html page using Javascript? If so, how can it be done? P.S the javascript will be hosted on my site, but I want users to be able to put in the <head> tag of their website, and it should be able to import a css file hosted on my server into

Get next / previous element using JavaScript?

How do I get the next element in HTML using JavaScript? Suppose I have three <div>s and I get a reference to one in JavaScript code, I want to get which is the next <div> and which is the previous. Answer Well in pure javascript my thinking is that you would first have to collate them inside a collection. So

How to create a tag with Javascript?

I’m looking for a way to insert a <style> tag into an HTML page with JavaScript. The best way I found so far: This works in Firefox, Opera and Internet Explorer but not in Google Chrome. Also it’s a bit ugly with the <br> in front for IE. Does anyone know of a way to create a <style> tag that

Creating a textarea with auto-resize

There was another thread about this, which I’ve tried. But there is one problem: the textarea doesn’t shrink if you delete the content. I can’t find any way to shrink it to the correct size – the clientHeight value comes back as the full size of the textarea, not its contents. The code from that page is below: Answer This

Where should I put tags in HTML markup?

When embedding JavaScript in an HTML document, where is the proper place to put the <script> tags and included JavaScript? I seem to recall that you are not supposed to place these in the <head> section, but placing at the beginning of the <body> section is bad, too, since the JavaScript will have to be parsed before the page is

How to prevent IFRAME from redirecting top-level window

Some websites have code to “break out” of IFRAME enclosures, meaning that if a page A is loaded as an IFRAME inside an parent page P some Javascript in A redirects the outer window to A. Typically this Javascript looks something like this: My question is: As the author of the parent page P and not being the author of

jQuery hover and class selector

I wan’t to change the background color of a div dynamicly using the following HTML, CSS and javascript. HTML: CSS: Javascript: EDIT: I forgot to say that I had reasons not to want to use the css way. And I indeed forgot to check if the DOM was loaded. Answer Your code looks fine to me. Make sure the DOM

Scroll to bottom of div?

I am creating a chat using Ajax requests and I’m trying to get messages div to scroll to the bottom without much luck. I am wrapping everything in this div: Is there a way to keep it scrolled to the bottom by default using JS? Is there a way to keep it scrolled to the bottom after an ajax request?

Advertisement