Solved

Javascript and using SSI exec command

Posted on 1998-08-20
7
446 Views
Last Modified: 2013-11-18
Hello,

I have the following problem using SSI together with
Javascript on MSIE or NEtscape or other browsers.

The folowing code wil look if you use frames or not.
The frame parts are called down and down_wevers.
There are 3 frame parts.
The script will work without SSI. I use it on othere applications.

I have now the following problem.
I wan't to use the exec SSI command.
But it must only be executed when goodlocation is not true and goodlocation_wevers is also not true.
I put the command to the else part.
But only putting it there will result in always executing the script as soon the html file is read by a browser.
I wan't it only be executed when the goodlocations are false!!!

I have tryed also the following.

<script language="JavaScript">
<!--

function FrameRedirectAXS()
{  
goodlocation=false
goodlocation_wevers=false
if (parent.frames.length != 3) goodlocation=false;
if (parent.frames.length == 3) {
      if (parent.frames[1].name == "down") goodlocation=true;
      if (parent.frames[1].name == "down_wevers") goodlocation_wevers=true;
}
if (goodlocation == true) document.write("");
else if (goodlocation_wevers == true) document.write("");
else document.write("<--#exec " + "cgi=\"/cgi-bin/axs/ax1.pl\"" + "-->");

}
//-->
</SCRIPT>

This wil result in a line <--#exec cgi="/cgi-bin/axs/ax1.pl"-->
this is the SSI line command.
But this tiime it will not be executed.
The browser will write down the
 <--#exec cgi="/cgi-bin/axs/ax1.pl"--> line and do noting with it.

It is possible for me to use SSI and I use it in SHTML files.

I call the javasript by using:

<SCRIPT LANGUAGE="JavaScript">
FrameRedirectAXS()
</SCRIPT>

How can I solve this problem????

Greeting Michel Weegerink
E-mail: mmcw@worldonline.nl
0
Comment
Question by:mmcw
7 Comments
 

Accepted Solution

by:
Visible_Man earned 200 total points
ID: 1269481
This only a small thing but JS is senitive to small things.  After an If...Then or Else...then logic put Brackets like so.
That maybe the problem bescause JS is very picky with stuff like that Hope it works :)

<script language="JavaScript">
    <!--

    function FrameRedirectAXS()
    {  
    goodlocation=false
    goodlocation_wevers=false
    if (parent.frames.length != 3) {goodlocation=false};
    if (parent.frames.length == 3) {
    if (parent.frames[1].name == "down") {goodlocation=true};
    if (parent.frames[1].name == "down_wevers") {goodlocation_wevers=true};
    }
    if (goodlocation == true) {document.write("")};
    else if (goodlocation_wevers == true) {document.write("")};
    else {document.write("<--#exec " + "cgi=\"/cgi-bin/axs/ax1.pl\"" + "-->")};

    }
    //-->
    </SCRIPT>
0
 
LVL 8

Expert Comment

by:jbirk
ID: 1269482
The problem is not due to syntax.  You cannot use clientside javascript to decide how server side includes will load.  The reason is because the include occurs when the file is first requested and the operation is performed by the server.  The browser has absolutely no idea that a server side include was even on the page.  And the JavaScript you wrote it client side, which means it is executed by the browser.  So once it has made it to the browser the server is finished with it, meaning that no more SSI's can be included.  When the browser writes out the SSI command exec, it just thinks it's a comment, and has no idea what to do with it.  If you want to do something like this, you'll have to either make seperate pages (one with the SSI and one without) and then decide which page will be loaded with javascript, or use something like server side javascript (which I don't really know how to use as the servers I use don't support it).

Hope this clears things up,
Josh
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269483
Also please remember that the script is inside comments
<SCRIPT><!--

--></SCRIPT>

and any SSI inside the script will never be executed even if you could make it work.
What is inside the ssi - could it perhaps be coded differently or can you have an
html file you load into a hidden frame that contains the ssi?
as in

 if (goodlocation == true) {document.write("")};
else if (goodlocation_wevers == true) {document.write("")};
else self.location = 'ssihtml.html';

Michel

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269484
Why not put the <SCRIPT><!--  and --></SCRIPT> and the rest of the html in the
/cgi-bin/axs/ax1.pl, then you could even do a

 if (goodlocation == true) {document.write("")};
       else if (goodlocation_wevers == true) {document.write("")};
       else self.location = '/cgi-bin/axs/ax1.pl';

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269485
Did the above accepted answer solve your question?

If yes, how and if not why accept it?

Michel
0
 

Author Comment

by:mmcw
ID: 1269486
It is not exacly what I mean al those answers but I now know that it is not possible in javascript and solved the problem an other way. Thank you for your support
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269487
Would you then in the future please reject the answer or have the customer services remove it?
Otherwise it will be autograded and put in the pool of accepted answers and Visible_Man's answer is a wrong rehash of the version answered in the CGI area.

Michel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now