473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Javascript to OPTIONALLY hide HTML/JS

Hi all:

Please excuse a newbie question but I could use some assistance.

I have a large number of "help pages" for an application which we provide.
Within those pages are sections of code that I want to conditionally comment
out. These sections include HTML and Javascript elements. A sample:

<p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help page.

I've tried to define functions optionalHelpStart and optionalHelpEnd which
would either be defined as empty (if we want the code above to be executed)
or as follows if we wanted to hide it:

function optionalHelpStart()
{
document.write ("<!--");
}

function optionalHelpEnd()
{
document.write<"-->");
}

and then recoding as follows:

<script language="javascript">optionalHelpStart();</script>
<p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help page.
<script language="javascript">optionalHelpEnd();</script>

but this doesn't work (even if I put it all on a single line).

Is there a simple way that I can get this to work? The major problem is that
we've got two products, one which supports the "advancedHelp" files and one
that does not and we don't want to maintain two sets of files (there are
something like 20 of them in each of 9 languages so far).

Thanks in advance.

- Dave
Jun 27 '08 #1
7 1093
"David In NH" <dg****@gmail.com>
<snip>
<p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help page.
Can't you give <pa class and hide the lot via CSS in the product where you
do not want to show this advanced help? It would remove all occurrences via
one simple parameter.
Tom
Jun 27 '08 #2

"Tom de Neef" <td*****@qolor.nlwrote in message
news:48***********************@news.xs4all.nl...
"David In NH" <dg****@gmail.com>
<snip>
><p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help page.

Can't you give <pa class and hide the lot via CSS in the product where
you do not want to show this advanced help? It would remove all
occurrences via one simple parameter.
Tom

Sorry Tom but I really am a newbie to this. I've inherited this work from
the original programmer and am not familiar with CSS. I'll look into it
though. Thanks for your suggestion.

- David
Jun 27 '08 #3
pr
David In NH wrote:
I have a large number of "help pages" for an application which we provide.
Within those pages are sections of code that I want to conditionally comment
out.
[...]

Sounds like you're trying to use JavaScript to counteract an authoring
problem. You might get something to work - at least on users' PCs that
have JavaScript available and enabled - but ISTM that you should be
looking instead at:

a. some kind of authoring system: content management software or a
custom solution (eg XHTML + XSLT).

b. server code (eg PHP, ASP) to disable the unwanted bits of web pages,
probably triggered by the query string (eg
'myhelp.html?product=standard|deluxe') and/or a cookie.

(b) is the quicker. (a) is the more sensible. JavaScript doesn't have a
lot going for it in this case.
Jun 27 '08 #4

"David In NH" <dg****@gmail.comschreef in bericht
news:8s******************************@comcast.com. ..
>
"Tom de Neef" <td*****@qolor.nlwrote in message
news:48***********************@news.xs4all.nl...
>"David In NH" <dg****@gmail.com>
<snip>
>><p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help
page.

Can't you give <pa class and hide the lot via CSS in the product where
you do not want to show this advanced help? It would remove all
occurrences via one simple parameter.
Tom


Sorry Tom but I really am a newbie to this. I've inherited this work from
the original programmer and am not familiar with CSS. I'll look into it
though. Thanks for your suggestion.

- David
<style>
p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
styles applicable to <p>
</style>

<p class=advancedall text here will not show unless you change the
stylesheet</p>

Tom
Jun 27 '08 #5

"Tom de Neef" <td*****@qolor.nlwrote in message
news:48***********************@news.xs4all.nl...
>
"David In NH" <dg****@gmail.comschreef in bericht
news:8s******************************@comcast.com. ..
>>
"Tom de Neef" <td*****@qolor.nlwrote in message
news:48***********************@news.xs4all.nl.. .
>>"David In NH" <dg****@gmail.com>
<snip>

<p>For more information <script language="javascript">advancedHelp("
<strong>Click Here</strong>","13.htm");</scriptto launch the help
page.
Can't you give <pa class and hide the lot via CSS in the product where
you do not want to show this advanced help? It would remove all
occurrences via one simple parameter.
Tom


Sorry Tom but I really am a newbie to this. I've inherited this work from
the original programmer and am not familiar with CSS. I'll look into it
though. Thanks for your suggestion.

- David

<style>
p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
styles applicable to <p>
</style>

<p class=advancedall text here will not show unless you change the
stylesheet</p>

Tom
Tom! You be da man! This is close to what I eventually winded up using (a
little bit of Javascript that expands to code similar to what you
suggested).

My work just got a lot easier!
Jun 27 '08 #6
Tom de Neef meinte:
<style>
p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
styles applicable to <p>
</style>
Rather set element.style.display to either "block" or "none".

You don't need to switch css classes.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #7
Tom de Neef wrote:
"David In NH" <dg****@gmail.comschreef in bericht
>"Tom de Neef" <td*****@qolor.nlwrote in message
>>Can't you give <pa class and hide the lot via CSS in the product where
you do not want to show this advanced help? It would remove all
occurrences via one simple parameter.
[...]
<style>
p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
styles applicable to <p>
</style>
If you are *this* sure, please refrain from posting your code in the future.
This does not even come close to CSS. Should be:

<style type="text/css">
p.advanced {
display: none;
}
</style>
<p class=advancedall text here will not show unless you change the
stylesheet</p>
All attribute values should be quoted.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
1
by: Oliver Hoehle | last post by:
Hello! This ist the source-code for an editable combobox implemented with HTML,CSS and Javascript. I have tested it with IE and Mozilla. But I don't know, if it will work in other browsers...
7
by: fernandoronci | last post by:
Hi, I've been given the task of mantaining and fixing a website which I didn't design. I'm using Internet Explorer 5.5 and 6.x. Specifically, the problem is that navigation menues (written in...
7
by: f1crazed | last post by:
Ok, The following html works wonderful in IE. It does not work in FireFox. Can someone please tell me the work around for FireFox to get this to work. HTML DOCUMENT: <html> <head>...
20
by: Shang Wenbin | last post by:
Hi, How to use javascript in php? I want to return some values to php. Thanks -- Shang Wenbin from Realss
4
by: -Lost | last post by:
I cannot for the life of me remember the site name, but I believe it was the site of one of the regular posters here or perhaps in comp.lang.java.javascript. Anyway... The site in particular...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
47
by: SOLAV | last post by:
This is the only working way to completely hide your JavaScript code from the client just like PHP or ASP code. Here we'll need the help of PHP. Here is the code: index.php...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.