Chicken
01-21-2004, 09:56 PM
I am developing a message board, and I have markup buttons (similar to the ones found on this board when you are posting) that users can press to pop up a box to accept input.
For example, check out this link:
One of my forums (http://www.tigerdroppings.com/rant/Message.asp?action=create&Post=New&BoardID=2&View=2)
These buttons work fine in Internet Explorer, but do not work for Netscape or the browser used by Macs.
This is the logic that I am now using for the "url" button:
<INPUT TYPE="button" VALUE="link" onClick="addSingleURL('Enter a valid URL:', 'Enter your link title:', 'http://'); frmPost.txtpost.focus(); return true;" id=button1 name=button1 title="Add Link">
And this is the logic for the javascript function:
function addSingleURL(prompt1, prompt2, defaultText)
{
// If something is selected then just encase it in the tags
var selection = document.selection.createRange().text;
if(selection != "")
{
document.frmPost.txtpost.focus();
var newSelection = document.selection.createRange();
var linktitle = self.prompt(prompt2, "LINK");
if((linktitle == "") || (linktitle == null))
linktitle = "LINK";
newSelection.text
= ''+linktitle+'';
return;
}
// Nothing's selected so prompt for something to put between the tags
var newTag = self.prompt(prompt1, defaultText);
if((newTag == null) || (newTag == defaultText))
return;
var linktitle2 = self.prompt(prompt2, 'LINK');
if((linktitle2 == "") || (linktitle2 == null))
linktitle2 = "LINK";
newTag=''+linktitle2+'';
document.forms.frmPost.txtpost.value += newTag;
}
frmPost is the name of the form that is defined on the page.
I need to know what I have wrong that is causing this not to work in Netscape and Safari(?). This has been driving me crazy, so I stumbled upon this forum seeking help.
Thanks in advance for your help.
For example, check out this link:
One of my forums (http://www.tigerdroppings.com/rant/Message.asp?action=create&Post=New&BoardID=2&View=2)
These buttons work fine in Internet Explorer, but do not work for Netscape or the browser used by Macs.
This is the logic that I am now using for the "url" button:
<INPUT TYPE="button" VALUE="link" onClick="addSingleURL('Enter a valid URL:', 'Enter your link title:', 'http://'); frmPost.txtpost.focus(); return true;" id=button1 name=button1 title="Add Link">
And this is the logic for the javascript function:
function addSingleURL(prompt1, prompt2, defaultText)
{
// If something is selected then just encase it in the tags
var selection = document.selection.createRange().text;
if(selection != "")
{
document.frmPost.txtpost.focus();
var newSelection = document.selection.createRange();
var linktitle = self.prompt(prompt2, "LINK");
if((linktitle == "") || (linktitle == null))
linktitle = "LINK";
newSelection.text
= ''+linktitle+'';
return;
}
// Nothing's selected so prompt for something to put between the tags
var newTag = self.prompt(prompt1, defaultText);
if((newTag == null) || (newTag == defaultText))
return;
var linktitle2 = self.prompt(prompt2, 'LINK');
if((linktitle2 == "") || (linktitle2 == null))
linktitle2 = "LINK";
newTag=''+linktitle2+'';
document.forms.frmPost.txtpost.value += newTag;
}
frmPost is the name of the form that is defined on the page.
I need to know what I have wrong that is causing this not to work in Netscape and Safari(?). This has been driving me crazy, so I stumbled upon this forum seeking help.
Thanks in advance for your help.