Ehsan Mahpour’s Weblog

Archive for November, 2006

Highlighting a text in a HTML page

by mahpour on Nov.14, 2006, under HTML/CSS Tips

Here is the javascript code which should be used somewhere on the bottom of html page (of course inside the script tags)

just replace "text_to_find" with your text (it could be a variable or a serverside string) without quotes. Also change CONTAINER_TAG_ID with the container id and enjoy.

document.getElementById("CONTAINER_TAG_ID").innerHTML= document.getElementById("CONTAINER_TAG_ID").innerHTML.replace(/(text_to_find)/gi,"< span style='background-color:yellow;'>$1< /span >");
Leave a Comment more...

Modal dialog box compatibility issue for IE and FireFox

by mahpour on Nov.05, 2006, under HTML/CSS Tips

I use Firefox exclusively and every now and then I come across a site that is crippled. This means that parts of it will not work in Firefox because the site is using some kind of IE only functionality.

One example is the function showModalDialog. This will create a modal pop-up when using IE but because it is not a W3C standard, it is not implemented in Firefox (Mozilla) and will just cause a JavaScript error.

Solution

Please refer to the following url to see an example that uses a javascript file to solve this issue.

http://www.hedgerwow.com/360/dhtml/dialog_window/dialog_window.htm

Unfortunatelly it desn’t work for Firefox 2 (I don’t know yet why)

Leave a Comment more...

Source Code syntax highlighting plugin for WordPress

by mahpour on Nov.03, 2006, under Plugins

Introduction

This plugin using Geshi to highlight source code in a wide range of popular languages,it aims to be a simple but powerful code highlighting plugin, with the following goals:

  • Easy to use
  • Support for a wide range of popular languages
  • Customizable output formats
  • Auto adjust the height of the Code Container if the code is too long

Installation

This plugin requires WordPress v.1.5 or later.

  1. Download Dean’s Code Highlighter v1.0 .
  2. unzip and upload the file into your wp-content/plugins/ directory.
  3. Activate the plugin on your Admin Panel->Plugin Management page.
  4. add the Code Container’s CSS classes to your style sheet.
  5. customize the output formats on Admin Panel->Options->Code Highlighter.

usage

Use the “pre” tag and add the programming language you want to use as a parameter. Example:. < pre lang="php" >your code here … < /pre >. for example:

< pre lang="php" > function hello_world(){ echo “hello world” } < /pre >after highlighting:

function hello_world(){ echo "hello world" }

Code Container Style

add the following CSS classes to your templates’s CSS file: .ch_code_container {
background-color: #f0f0f0;
border: 1px solid #C3CED9;
padding: 0px 0px 0 0;
width: 100%;
text-align: left;
font-size:1.00em;
overflow:auto;
}
.ch_code_container .head
{
color: #808080;
font-weight: bold;
background-color: #f0f0ff;
border-bottom: 1px solid #d0d0d0;
padding: 2px;
}

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...