|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hey can somebody help out to why I am receiving the following JavaScript Error?
'selFont' not defined. This error on occurs when I go to change the heading size or view the HTML in the editor??? How do you define a variable in JavaScript...
__________________
Moojjoo |
|
#2
|
||||
|
||||
|
var selFont
But you might be missing some code that would have all those var's setup for you. |
|
#3
|
|||
|
|||
|
JavaScript Errors cont.
Stumpy thanks for the advice.
I added: var selectFont and now I am getting this error. 'options' is null or not an object The strange part about this whole thing is when I remove the following from my page I do not get these errors... <form onSubmit="return ProcessDocument();" name="frmDocument" action="documentPoster.asp" method="post"> My code for this heading change is the following: <select name="selHeading" onChange="doHead(this.options[this.selectedIndex].value)"> <option value="">-- Heading --</option> <option value="Heading 1">H1</option> <option value="Heading 2">H2</option> <option value="Heading 3">H3</option> <option value="Heading 4">H4</option> <option value="Heading 5">H5</option> <option value="Heading 6">H6</option> </select> Script: function doHead(hType) { if(hType != '') { var selFont iView.document.execCommand('formatblock', false, hType); doFont(selFont.options[selFont.selectedIndex].value); } } |
|
#4
|
|||
|
|||
|
Reply
However the heading does change font size...
|
|
#5
|
||||
|
||||
|
It could be anything - I don't wanna get into it all, cos the code off the site works as is. I'd say you've maybe just made a typo, or left out a chunk of functions or something. Have another crack at it and see how you go.
|
|
#6
|
|||
|
|||
|
Code off the Site???
The author of the site did not include the code to the second part of the article, so how can you tell if it works???
|
|
#7
|
|||
|
|||
|
Stumpy,
Thanks for the motivation. The code causing the problem was the addition of the form tag. When adding the Form you have to change your DOM reference in the Javascript... function doHead(hType) { if(hType != '') { var selFont = 1 iView.document.execCommand('formatblock', false, hType); //alert(hType + selFont) doFont(document.frmDocument.selFont.options[document.frmDocument.selFont.selectedIndex].value); } } function doToggleView() { if(viewMode == 1) { iHTML = iView.document.body.innerHTML; iView.document.body.innerText = iHTML; // Hide all controls tblCtrls.style.display = 'none'; document.frmDocument.selFont.style.display = 'none'; document.frmDocument.selSize.style.display = 'none'; document.frmDocument.selHeading.style.display = 'none'; iView.focus(); viewMode = 2; // Code } else { iText = iView.document.body.innerText; iView.document.body.innerHTML = iText; // Show all controls tblCtrls.style.display = 'inline'; document.frmDocument.selFont.style.display = 'inline'; document.frmDocument.selSize.style.display = 'inline'; document.frmDocument.selHeading.style.display = 'inline'; iView.focus(); |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > WYSIWYG Editor |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|