Cannot set breakpoint on a particular line of IE - javascript

I am experimenting TinyMCE editor to set its content on click of an hyperlink. For this I used their own demo page and tried adding a link their. But clicking on link did not set the content of the editor. So I went on debugging it in IE9. I tried putting breakpoint on the line, but surprised - I was able to toggle breakpoint everywhere, except that line.
snapshot here: http://s15.postimage.org/a7ntjabfv/Tiny_MCE_Debug.png
Why is this happening?

Actually, now that you mentioned it...I figured what happened.
The line where you're trying to set the breakpoint looks like invalid html, so IE behaves correctly.
In your example, html attributes (like the onclick you have) are delimited by double quotes ("). But you also have another string delimited by " inside the attributes, which leads to a syntax error. To get around this, you must delimit your strings by single quotes: ' . So the solution that you found is correct.

Related

Invalid filter name "Javascript" in HAML

While writing some HAML for a Rails application, I tried to use the :javascript filter to embed some inline javascript into the document. Whenever I try to load the page, Rails complains with Invalid filter name ":javas­cript". The code I am trying to include is the following:
:javas­cript
$(document).ready(function() {
$('#variants').editableTableWidget();
});
Why is rails complaining?
You seem to have somehow got an extra character in your code, a “soft hyphen” (U+00AD), between the s and c of “javascript”. It doesn’t show up in the HTML, but copying your code and pasting into the terminal to run it reveals the extra character, and the error message appears as
Invalid filter name ":javas-cript".
(here I’ve replaced the soft hyphen with a normal one so that it shows up in the HTML)
It might not show up in your editor, but if you advance your cursor over the word one character at a time you may notice you need an extra key press between the s and c.
To fix it, just delete this extra character. If you can’t find it or are unsure, delete the whole javascript and retype it.

Strange json.stringify fail

Strange is not the error itself but the way it happens. In my content editor while editing everything gets saved with unique id's in a javascript object and after you save in the end it gets json stringified. That work's for 99,99% of my users perfect but sometimes json.stringify didn't escape the quotes and its always happens with the same beginning. I really don't have a clue how this happens. Here is a picture of the javascript object:
http://cl.ly/image/3B3Z2e413M3r
Off course the marked line is the error but the whole thing (no escaped quotes) only occures if the content starts with this line. I should mention if you load a wysiwyg element in the editor there is a pre equipped < h3 >...< /h3 > and a < p >...< /p > with some sample data. (the h3 is not centered per default)
<h3 style="text-align: center;">Sample Headline</h3>
My problem is that i can't reproduce it. If i align my heading to get the same code, everything works well. Users got the last chrome version and there is no other plugin then jQuery.
Any ideas would be great because iam exhausted...
Cliffnotes:
json.stringify failes to escape quotes and....
everytime the error occurs to a user i see that it starts with the aligned heading so i guess it has something to do with it
Thanks a lot. :)
What you have shown is a normal JS object and not a JSON (so it has nothing to do with JSON.stringify()). The quotes must be only escaped in string literals in code, so that interpreter did not confuse it with delimiting quotes.
After it's parsed - they are stored in memory as-is without any escape characters.
Example: http://jsfiddle.net/83GUe/
Guide: open developer tools, press Run and see the Scope variables
Conclusion: what you provided on a screenshot is a 100% expected and correct behaviour.

Add line break inside bookmarklet

I have a bookmarklet that allows me to wrap any function and insert a debugger statement before it is called.
It works fine, but since the bookmarklet is a single line debugger stops somewhere in the middle of a long string of code and I need to scroll to find the breakpoint.
How can I insert a new line character after the debugger statement so that when it's encountered the code in the console is split into two lines?
The \n and literal newline character copied from a textarea into the bookmarklet don't split lines in the debugger.
Generally, it is best to URL-encode a bookmarklet before storing in a bookmark. So you can have a multiline bookmarklet simply by encoding the newlines, as demonstrated by this: encodeURIComponent("alert('line1');\nalert('line2');")
That answers the question as you asked it, but I'm not sure if this is your real problem. If you provide example code I might be able to give further advice.
No, bookmarklets are always one-liners.
You can use the chrome debugger which has a "prettify code" option.
Another option would be not running it as a normal bookmarklet during debugging but injecting a script tag pointing to a properly formatted version of your script.

Custom mark up language breaks html

I am using document.write to output HTML to the browser ( I plan to change to .innerHTML soon).
When using view source I can only see the markup, I can not see the HTML output. However I verified visually that rows 1 and 2 of 0 through 6 are completely missing and commented as such below.
When I inspect the mark up below I see that these two rows have many special characters which leads me to believe this might be the problem.
Note:
Each row is divided by a || and each field is divided by a |. The markup lanaguage is properly escaped as you can see there are no superfulous | or ||.
Actually I just noticed the tag is being cropped for some reason:
https://www.google.com/#hl=en&sclient=psy-ab&q=new+york+city+venture+capitalists&pbx=1&oq=new+york+city+venture+capitalists&aq=f&aqi=&aql=&gs_sm=12&gs_upl=0l0l0l98460l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=94def8e69f73d3d7&biw=1214&bih=852
becomes
<a class=\'bookmark_tweet\' target=\'_blank\' href=\'https://www.google.com/#hl=en&sclient=psy-ab&q=new+york+city+venture+cap
I'll post relevant code once I get it:
View source shows you what was received from the server. If you add to it using document.write() you won't see that unless you use a DOM inspector in your browser, such as firebug (Firefox). I know there is one for IE but never use IE so I don't know what it's called.
Javascript strings don't span lines. You can't open a quote on one line, then close it on another.

Listexpander not working

my website the list expander is not working. I think it might be because I changed the CSS, but I cannot figure out how to make it work.
Sorry the url is [http://hpcommtoolkit.com/Communication_tools.html][2] not the original.
[2]: http://hpcommtoolkit.com/Communication_tools.html
What list needs to be expanded? What code do you use for it?
Not sure what list you are referring to, however there is a fault in your HTML at line 405 with the style tag on the table which you should probably clean up:
style="BACKGROUND-IMAGE: url<img src="//images/afbottomgraphic.jpg"
The second double quote is ending the style tag prematurely. Background-image should be given a url in the form of url(path-to-file).
EDIT: Ok, I see your expandable sections in the new URL. They work correctly in Firefox, but IE8 is generating the following error: "Object doesn't support this property or method listexpander.js, line 69 character 3".
Looking at that line of code, the first thing I can see is that the variable "li" should have a "var" declaration on it to avoid it interfering with any global vars. I would also recommend running listexpander.js through jslint (http://www.jslint.com/) since the syntax has a few oddly positioned semi-colons.

Categories