<script type="text/javascript"> <!-- function linkage(tag){ var url = prompt("please input url,","http://"); if((url != "") && (url != null)){ var ans = url.match(/(http|ftp):\/\/[a-zA-Z0-9_\.\~\-\/\?\&\+\=\:\;\@\%\#]+/); if((ans != "") && (ans != null)){ var txt = prompt("& text for a link.",""); var obj = document.getElementById("text"); if((txt != "") && (txt != null)){ obj.value += '<' + tag + ' href="' + url + '" target="_blank">' + txt + '</' + tag + '>'; obj.focus(); obj.value += ""; document.getElementById("a").checked = false; }else if(txt == ""){ obj.value += '<' + tag + ' href="' + url + '" target="_blank">' + url + '</' + tag + '>'; obj.focus(); obj.value += ""; document.getElementById("a").checked = false; }else if(txt == null){ obj.focus(); obj.value += ""; document.getElementById("a").checked = false; }else{ document.getElementById("a").checked = false; alert("incorrect text!"); } }else{ document.getElementById("a").checked = false; alert("incorrect url!"); } }else if(url == ""){ document.getElementById("a").checked = false; alert("incorrect url!"); }else if(url == null){ document.getElementById("a").checked = false; }else{ document.getElementById("a").checked = false; alert("incorrect url!"); } } function wrapper(tag){ var txt = prompt("please input text.",""); if((txt != "") && (txt != null)){ var obj = document.getElementById("text"); obj.focus(); obj.value += ""; obj.value += '<' + tag + '>' + txt + '</' + tag + '>'; document.getElementById(tag).checked = false; }else if(txt == ""){ document.getElementById(tag).checked = false; alert("incorrect text!"); }else if(txt == null){ document.getElementById(tag).checked = false; }else{ document.getElementById(tag).checked = false; alert("incorrect text!"); } } function popup(tag,filename,newwin){ var W = 300; var H = 300; var L = Math.round((screen.width-W)/2); var T = Math.round((screen.height-H)/2); var F = filename; var S = newwin; var menu = ""; menu += '"' + F + '",'; menu += '"' + S + '",'; menu += '"toolbar=no,'; menu += 'location=no,'; menu += 'directories=no,'; menu += 'status=no,'; menu += 'menubar=no,'; menu += 'scrollbars=no,'; menu += 'resizable=yes,'; menu += 'left=' + L + ','; menu += 'top=' + T + ','; menu += 'width=' + W + ','; menu += 'height=' + H + '"'; eval(S + "= window.open(" + menu + ")"); } function erase(){ var txt = ""; document.getElementById("text").value = txt; } //--> </script>
<form name="comments_form"> 中略・・・ <input type="radio" name="supple" value="a" id="a" onClick="linkage('a')"> <a> <input type="radio" name="supple" value="b" id="b" onClick="wrapper('b')"> <b> <input type="radio" name="supple" value="em" id="em" onClick="wrapper('em')"> <em> <input type="radio" name="supple" value="i" id="i" onClick="wrapper('i')"> <i> <input type="radio" name="supple" value="strong" id="strong" onClick="wrapper('strong')"> <strong> <input type="radio" name="supple" value="blockquote" id="blockquote" onClick="popup('blockquote','blockquote.htm','blockquote')"> <blockquote> 中略・・・ </form>
"blockquote"のラジオボタン部分より、
<input type="radio" name="supple" value="blockquote" id="blockquote" onClick="popup('blockquote','blockquote.htm','blockquote')"> blockquote.htm → 絶対パス
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>blockquote</title> <script type="text/javascript"> <!-- function exe(tag){ var txt = document.getElementById("text").value; if(txt != ""){ var R; var others = false; var num1 = txt.indexOf("\r\n"); (num1 != -1)? R = "\r\n" : others = true; if(others){ var num2 = txt.indexOf("\r"); (num2 != -1)? R = "\r" : R = "\n"; }else{ R = ""; } //var Q = R + ">"; //var lines = txt.split(R); //txt = lines.join(Q); var obj = opener.document.getElementById("text"); obj.focus(); obj.value += ""; obj.value += R + '<' + tag + '>' + R + txt + R + '</' + tag + '>' + R; opener.document.getElementById(tag).checked = false; window.close(); }else{ alert("incorrect text!"); } } function start(){ document.getElementById("text").focus(); } function end(tag){ opener.document.getElementById(tag).checked = false; } function can(tag){ opener.document.getElementById(tag).checked = false; window.close(); } //--> </script> <style type="text/css"> <!-- a { text-decoration: underline; } a:link { color: #CC99FF; } a:visited { color: #CCCCFF; } a:active { color: #CCCCFF; } a:hover { color: #CCCCFF; } .main { color: #333333; font-family: Arial, Verdana, sans-serif; font-size: 12px; text-align: left; line-height: 150%; margin-top: 15px; margin-right: 15px; margin-bottom: 15px; margin-left: 15px; } --> </style> </head> <body class="main" onBlur="window.focus()" onLoad="start()" onUnload="end('blockquote')"> *Excerpt from ... <form> <textarea id="text" rows=12 cols=24></textarea><br> <input type="button" value="Cancel" onClick="can('blockquote')"> <input type="button" value="Submit" onClick="exe('blockquote')"> </form> </body> </html>
sub html_text_transform { my $str = shift; $str ||= ''; my @paras = split /\r?\n\r?\n/, $str; for my $p (@paras) { if ($p !~ m@^</?(?:h1|h2|h3|h4|h5|h6|table|ol|dl|ul|menu|dir|p|pre|center|form|fieldset|select|blockquote|address|div|hr)@) { $p =~ s!\r?\n!<br />\n!g; $p = "<p>$p</p>"; } } join "\n\n", @paras; }