DOM based scripting - javascript

ok so here's my problem...
i've been following this tutorial ( http://www.alistapart.com/articles/dropdowns )
to make a css drop down menu with my wordpress blog. everything works fine... except in IE6.
now i know this is normal, and in the link i posted above there is a fix of this which makes use of DOM based scripting... is this java script?
the main question i have is.. where do i paste this code into? css, html, make a new file?
i'm new to any form of javascript.. it's boggling me a bit..
any help would be great!
Thanks!
yours truly
noobie

Yes, it is JavaScript.
As such, you can place it in a <script> block, preferrably inside <head>. (It assigns itself to window.onload, so the code will be executed at onload, no matter where in the page you put the code)

the main question i have is.. where do i paste this code into? css, html, make a new file?
I suggest you take a look at the source of this sample page:
http://www.htmldog.com/articles/suckerfish/bones/. It shows the bare details of how it's implemented.
i'm new to any form of javascript.. it's boggling me a bit..
I would like to suggest you read this nice tutorial which already helped out numerous developers during the years: w3schools.com/js.
Grz, Kris.

Related

Converting an HTML Java script to work with ASP.Net C#

Good day everyone,
I have been tasked with recreating a page that was originally written in HTML, to aspx.
I have successfully recreated the page and added additional functionality, but the main thing is it's suppose to run a java script once the submit button is hit.
I have the provided java, but don't really understand how to get it to work with my page.
I'm not even sure where to put the java code to begin with. The other examples online I couldn't make sense to what im trying to do. Please help.
Took a screen shot since it cuts out a lot of my code for some reason.
You can bind the submit button to a event and run the code inside the script in it.
Something similar to this:
$("#[YOUR_SUBMIT_ID_BUTTON]").on('click', function(e) {
e.preventDefault();
//Your JavaScript Code
});

How to filter in CKEditor?

How are you guys doing?
I am recently doing applying CKEditor to my corp's editor.
It's been great though I've got stuck in some problem.
I expect it to be the best even when we paste other contents from web or Word, but What blocks me doing is something kind of inline style tag, such as 'p style....' since it won't take its style away that my viewer doesn't seem to keep the same form.
I found out that filter.js would be the perfect solution for it. But there doesn't seem to be any way I can handle in my IDE since it doesn't exist.
How can I find a file called 'filter.js' or other plug-in so that I can handle the other way. this is the URL which would be help.
http://docs.ckeditor.com/source/filter.html#CKEDITOR-filter
Thanks.
Do I have to make new file called filter.js so I can edit on my own.
So confused. Hope to get some nice solution to it. Thanks.
CKEditor has a robust content filtering system called ACF (Advanced Content Filter). Read more about it here: http://docs.ckeditor.com/#!/guide/dev_acf and see the samples here: http://sdk.ckeditor.com/samples/acf.html. It's highly flexible so you can customize it to your needs.

How can I implement a Javascript/HTML Playground with Javascript?

I would like to implement a simple Javascript Playground like jsFiddle and was wondering on the best way to achieve this. From the way jsfiddle works, it creates an iframe with the submitted HTML/Javascript code. The source of the iframe comes from a dynamically created page from the jsfiddle server.
I was wondering if it would be possible to do this with client side javascript code only. I have tried this but does not work (custom code is not executed and do not know if jquery is loaded in the iframe):
$iframe = $(document.createElement("iframe"))
$html = $iframe.contents().find("html")
//HTML code
$html.children("body").append($(htmlcode))
//Javascript code (first jquery and then custom code)
$script = $(document.createElement("script"))
$script.attr("src","jquery.js")
$html.children("head").append($script)
$script = $(document.createElement("script"))
$script.html(javascriptcode)
$html.children("head").append($script)
$iframe.appendTo($("body"));
You don't have to be that complex.
Just open a new window (or an iframe) and put your HTML inside it.
Demo: http://jsfiddle.net/DerekL/uSrU6/4 (UPDATED)
also I'm not completely sure I understand what exactly are you trying to do. I think you have a mistake in the code you posted:
You are trying to append the script to $html.children('head') while $html is not the $iframe itself but the contents.. I think contents() doesn't return a DOM element so the rest after that isn't valid anyway. edit - now I see in the comments that regular js does work for you so this probably ain't the problem
I vaguely remember there is an issue with cross site scripting when calling js libs from another domain in an iframe. Not sure about that
EDIT: Found it: here maybe this is the issue. There is also a solution here

How to highlight (un)used JavaScript live in Dreamweaver

I am working in Dreamweaver CS4 and implemented JQuery code that I found online for a gallery function.
I am only using a very small part of the gallery functions available, and would like to delete the unused script in order to get more clarity and a cleaner script. But as a JavaScript beginner I can't identify what is important and what is not.
My question: Is there a way in Dreamweaver to view/highlight the JS code that the site is using? I am imagining a tool that you could turn on when running the live view that would visualize the portions of code that is being used.
Or, the other way round, is there a way to highlight the unused code.
The live code button doesn't seem to do this.
Thanks for your help!
My question: Is there a way in Dreamweaver to view/highlight the JS code that the site is using?
No. You would need to use Firebug or a similar javascript tracker/debugger to see how the code is used. The most DW will tell you is which external files are linked to a page.

Detecting javascript in HTML

I have two applications where users can submit HTML pages. I would like to make sure that no scripts are included in the HTML.
Normally you would escape content to get rid of scripts, but as this is HTML I can't do that. Anyone with good suggestions on how to do that? The applications are written in both C# and Java
OWASP has a project to scrub html and css
The first thing I'd do is see if there is a <script> tag in the HTML. That solves the first issue, then you have to make sure there are no inline onmouseover/onclick etc. events. You could maybe use a DOM Parser to go over all elements and remove all attributes that start with 'on'.
I have little to no experience in both C# as Java, so am unaware of any "easier" solutions that area already available. But maybe someone else here has a better idea for that.

Categories