-1

I am doing a MVC App. IT is a migration from ASP.NET.

in my _Layout I have a Footer that shows a message with a link to show Terms and Conditions. That Link opens a Htm with all legal advices.

My intention is that Link calls a JavaScript action that open the Htm page. Like this.

 function ShowTerms() {
            document.bgColor = "#E9EAED";
            oReturn = window.showModalDialog('TermsAndConditions.htm', window, 'dialogHeight:680px;dialogWidth=620px;resizable:no;status:no; help:no');
            document.bgColor = "";
        }

My JavaScript call is like this.

<span class="Term" onmouseover="this.style.cursor='pointer'" onclick="javascript:ShowTerms();">Terms y Conditions</span>

I have several erros when I display it. IIS do not find the page, and things like this.

Is that posible? or I have to call a Controller, Action Method and open it with Boostrap ShowModal?

Thanks

tereško
  • 58,060
  • 25
  • 98
  • 150
Diego
  • 2,238
  • 4
  • 31
  • 68
  • You can give your link an id and then refer that id in your Javascript and write a function for it. – Alf Moh Jan 27 '17 at 19:01
  • You mean to call a HTML.ActionLink?. I added how I call me JavaScript function.. thanks – Diego Jan 27 '17 at 19:06
  • I assume this is asp.net-mvc? (you need to tag you question correctly) –  Jan 28 '17 at 03:55

2 Answers2

0

Try this

<span class="Term" onmouseover="this.style.cursor='pointer'">Terms y Conditions</span>

var ele = document.getElementsByClassName("Term")[0];

ele.addEventListener("click",function() {
        document.bgColor = "#E9EAED";
        oReturn = window.showModalDialog('TermsAndConditions.htm', window, 'dialogHeight:680px;dialogWidth=620px;resizable:no;status:no; help:no');
        document.bgColor = "";
    });

I don't know what browser you are using but Window.showModalDialog() is deprecated in modern browsers. You can read about it here. Another option you can use which you can also read about here

Community
  • 1
  • 1
Alf Moh
  • 7,159
  • 5
  • 41
  • 50
0

Another working example.

<dialog>
<p>
    <q id="linkId"></q>
</p>
</dialog>

<span class="Term" id="show" onmouseover="this.style.cursor='pointer'">Terms y Conditions</span>



document.getElementById('show').onclick = function(e) {
e.preventDefault();
document.bgColor = "#E9EAED";
var link = document.getElementById('linkId');
link.innerHTML = window.open('http://www.mozilla.org','popup','width=600,height=600'); return false;}; 

You could try it here.

Alf Moh
  • 7,159
  • 5
  • 41
  • 50