Solitary
Solitary

Reputation: 1

Javascript, lines too long in text editor

50 years old, don't have time to spend 6 months learning JavaScript just to do one thing. Comments indicate question too verbose. 1 Found code for blocking JavaScript auto refreshing on a forum. 2 Did web search. 3 Don't know anything about JavaScript. 4 Found conflicting/confusing information. 5 Needed further explanation. The following is the code :

    user_pref("capability.policy.policynames", "reload");
    user_pref("capability.policy.reload.Location.reload", "noAccess");
    user_pref("capability.policy.reload.sites", "http://www.drudgereport.com http://news.yahoo.com");

To add more sites, you simply placed the new site URL into the "" quoted text, making sure to have a space between the URLS. 1. That string could stretch to 100's/1000's of characters. 2. Would look ugly/require scrolling text editor window for days to check for spaces.

Just wanting the code to look good and be able to see everything in the text editor on the code itself (without breaking script execution). Do I just hit enter around the 80 character mark (say after one of the URLS) or do I want to use the \n for a line break?

Thanks for that answer Blender. Not trying to be contentious, didn't know stackoverflow was at a premium for words, edited for brevity. 4 short paragraphs + short code snippet. Hope that is brief enough, can't think of much way to shorten. Out.

Upvotes: 0

Views: 774

Answers (3)

Golf Cz4
Golf Cz4

Reputation: 1

    user_pref("capability.policy.policynames", "reload");
    user_pref("capability.policy.reload.Location.reload", "noAccess");
    user_pref("capability.policy.reload.sites", "http://www.drudgereport.com http://news.yahoo.com");

Upvotes: 0

Blender
Blender

Reputation: 298046

You can put them into an array:

var websites = [
    'http://www.drudgereport.com', 
    'http://news.yahoo.com',
    ...
];

And then join them together to form your string:

user_pref("capability.policy.reload.sites", websites.join(' '));

Or all at once:

user_pref("capability.policy.reload.sites", [
    'http://www.drudgereport.com', 
    'http://news.yahoo.com',
    ...
].join(' '));

Upvotes: 2

Jonathan P
Jonathan P

Reputation: 458

why not just use word wrap if using Notepad++?

  1. Select “View” from menu bar.
  2. From the dropdown menu that appears click on “Word wrap” option.
  3. The same procedure is used to swap between Word wrap On & Off.

Upvotes: -1

Related Questions