Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript validation error

    this is how i call the editor:

    Code:
    	<!-- editor -->
    	<? include "js/editor/buttons.php"; ?>
    	<iframe id="textbox" class="Eddietor" src="js/editor/editor.php"></iframe><br />
    	<input type="hidden" id="content" name="content">
    	<!-- /editor -->
    and this is editor.js:

    Code:
    window.onload = function()
    {
    	Editor = document.getElementById('textbox').contentWindow.document;
    	Editor.designMode = "on";
    	document.forms[0].onsubmit = function()
    	{
    		var text = document.getElementById('text');
    		text.value = Editor.body.innerHTML;
    	}
    }
    
    function doColor(colour)
    {
    	document.getElementById("textbox").contentWindow.focus();
    	document.getElementById("textbox").contentWindow.document.execCommand("forecolor",false, colour);
    }
    
    
    
    function doClick(command) {
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById("textbox").contentWindow.document.execCommand(command, false, null);
    }
    function doLink() {
    var mylink = prompt("URL:", "http://");
    if ((mylink != null) && (mylink != "")) {
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById('textbox').contentWindow.document.execCommand("CreateLink",false,mylink);
    }
    }
    function doImage() {
    myimg = prompt('URL:', 'http://');
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById('textbox').contentWindow.document.execCommand("InsertImage", false, myimg);
    }
    another script i made is having problems with the ID="textbox" , it might be fixed if i change id and start using name="textbox" instead,
    but i don't know how to do this in js. need to edit the editor.js and change id="textbox"->to->name="textbox"
    can anyone help me? i got no idea how to use the getElementByName thingie , i'm trying to do this for 4 hours already and still no go.

    appreciated.
    Last edited by madscr2k; 08-29-2011 at 05:25 PM.

  • #2
    Regular Coder
    Join Date
    Aug 2011
    Location
    U.S.A.
    Posts
    233
    Thanks
    2
    Thanked 48 Times in 48 Posts
    If you are going to be using the name field instead of the id, you can directly access the element via dot notation:

    Code:
    document.formname.elementname.contentWindow.focus();

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    could you please give me another example of it ?
    so il know where to put it exactly in js file

    having troubles.


  •  

    Posting Permissions

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