为什么.php被保存/打开而不是我点击按钮时显示的新页面?

时间:2014-05-29 23:05:59

标签: javascript php html hyperlink

我有以下generateLink函数,它表示为LPE创建页面但是当我单击LPE页面中的按钮时,它会询问我是否要打开IAT.php文件而不是显示gInstruct1 .html for it,如下所示。你能指导我做错了吗?

enter image description here

因此,当我点击html时,我希望以下页面显示以下Concepts and Images Studyenter image description here

<html>
<!-- Thin People         Fat People -->
<p style="margin-left:30px">In this task, you will be classifying concepts and images 1. Each concept or image will appear in the center of the screen, for example,</p>
</br>
</br>
</br>
<img src="GSE-GPE-02.png" class ='instrItem' style="margin-left:33%;"/>
</br>
</br>
</br>
<div style="text-align:center">Press the <b>space bar</b> to continue.</div></html>

然而,当我点击该按钮时,我会收到以下内容: enter image description here

这是index2_4.html generateLink函数:

function generateLink() {
    var linktext;
    if (Math.random() < 0.5) {
        if (Math.random() < 0.5) {
            //GSE
            //linkText = "<p>In this study, you will complete a reaction-time GSE task using your computer. You can find the task at this link: </p><a href='http://langcomplab.net/Concepts&Images/GSE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";
            linkText = "<p>In this study, you will complete a reaction-time GSE task using your computer. You can find the task at this link: </p><a href='GSE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";

        } else {
            //GPE

            linkText = "<p>In this study, you will complete a reaction-time GPE task using your computer. You can find the task at this link: </p><a href='GPE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";

            //   linkText = "<p>In this study, you will complete a reaction-time GPE task using your computer. You can find the task at this link: </p><a href='http://langcomplab.net/Concepts&Images/GPE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";
        }
    } else {
        if (Math.random() < 0.5) {
            //LSE
            //linkText = "<p>In this study, you will complete a reaction-time LSE task using your computer. You can find the task at this link: </p><a href='http://langcomplab.net/Concepts&Images/LSE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";

            linkText = "<p>In this study, you will complete a reaction-time LSE task using your computer. You can find the task at this link: </p><a href='LSE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";
        } else {
            //LPE
            linkText = "<p>In this study, you will complete a reaction-time LPE task using your computer. You can find the task at this link: </p><a href='LPE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";

            //                        linkText = "<p>In this study, you will complete a reaction-time LPE task using your computer. You can find the task at this link: </p><a href='http://langcomplab.net/Concepts&Images/LPE_new/IAT.php' target='_blank'> Concepts and Images Study</a>";
        }
    }
    $('#iatLink').html(linkText);
}

2 个答案:

答案 0 :(得分:2)

查看浏览器网址输入,您似乎没有使用http服务器,而是直接从桌面访问该文件。正如Victory指出的那样,使用带有http协议和fcgi的Web服务器。 Apache或者如果您愿意,可以根据您使用的平台选择WAMP或LAMP或MAMP。

答案 1 :(得分:0)

如果您在计算机上运行以下命令,他们将安装Apache / PHP,以便您的PHP脚本能够正确运行。

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

完成此操作后,请将您的网站放入:

/var/www/html/

然后在浏览器中导航到:

http://localhost/

你应该看到你的网站。