Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2005, 01:13 PM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Toolbar in FireFox - Urgent Help Needed

Hey there

I'm an ASP coder and I'm building a web portal that involves a lot of user submissions. I made a text formatting toolbar in javascript which was basedon an oreillynet tutorial, but now I'm having problems. It appears that it works fine in IE, but refuses to work at all in Firefox. I've spoken to a few people on my usual ASP forum and they tell me that's because the code is "non standard" and firefox does not support non standard code. Anyway I'm here, basically to beg for help on making my code Javascript 'standard' Can anyone help?

My JavaScript functions are;

Code:
<script>
function format_sel(v) {
  var str = document.selection.createRange().text;
  document.form1.strMessage.focus();
  var sel = document.selection.createRange();
  sel.text = "[" + v + "]" + str + "[/" + v + "]";
  return;
}

function format_sml(v) {
  var str = document.selection.createRange().text;
  document.form1.strMessage.focus();
  var sel = document.selection.createRange();
  sel.text = v;
  return;
}

function insert_link() {
  var str = document.selection.createRange().text;
  document.form1.strMessage.focus();
  var my_link = prompt("Enter URL:","http://");
  if (my_link != null) {
    var sel = document.selection.createRange();
    sel.text = "[link]" + my_link + "[name]" + str + "[/name][/link]";
  }
  return;
}

function mouseover(el) {
  el.className = "raised";
}

function mouseout(el) {
  el.className = "button";
}

function mousedown(el) {
  el.className = "pressed";
}

function mouseup(el) {
  el.className = "raised";
}
</script>
And its called like this (example creates "bold" text)

Code:
<img class="button" 
 onMouseOver="mouseover(this);" 
 onMouseOut="mouseout(this);" 
 onMouseDown="mousedown(this);" 
 onMouseUp="mouseup(this);" 
 onClick="format_sel('b');" 
 src="../images/bold.gif"  
 align="middle" 
 alt="click to make your selection bold">
Any help would be very appreciated.

 
Old December 9th, 2005, 01:59 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Holy text selection batman! :0)

I don't think this particular aspect of JavaScript has anything to do with standards, as there is no standard method of working with selected text, AFAIK. See the Quirksmode link below for the various methods supported by different browsers.

http://www.quirksmode.org/index.html?/js/selected.html

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent help needed ramabharti Javascript How-To 2 November 21st, 2006 01:17 AM
Urgent Help Needed rameshnarayan XSLT 0 September 19th, 2005 03:46 AM
Buttons of different sizes needed in the toolbar Jell General .NET 8 May 3rd, 2005 08:48 AM
urgent help needed sugandh .NET Web Services 0 January 10th, 2004 12:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.