SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot superbrava's Avatar
    Join Date
    Aug 2001
    Location
    Indianapolis, IN
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Previewing contents in a textarea

    This works when i call the function with a link... when i close the window, and try and open it again, i get an error.

    Code:
    	function previewTextarea() {
    		previewTextarea = document.getElementById('textarea').value;
    		if(previewTextarea != "") {
    			window_previewTextArea_name = "js_popup_win";
    			window_previewTextArea = window.open("",window_previewTextArea_name,config="width=400,height=400,menubar=0,toolbar=0,scrollbars=1,location=0,directories=0,status=0,resizable=1");
    			window_previewTextArea.document.write("<a href=\"javascript:window.close();\">[ Close Window ]</a>");
    			window_previewTextArea.document.write("<hr />");
    			window_previewTextArea.document.write(previewTextarea);
    		} else {
    			alert("The textarea is empty or of a null value.  Operation failed.");
    		}
    	}
    any ideas?
    Steve v3.2.2 running on LocalSuck port 80

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works fine for me if I add "var" in front of the variables
    (otherwise error the first time...)
    Code:
    function previewTextarea() {
      var previewTextarea = document.getElementById('textarea').value;
      if(previewTextarea != "") {
        var window_previewTextArea_name = "js_popup_win";
    etc
    etc


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •