Want to create popup window from login page (using javascript)

Want to create popup window from login page (using javascript)

by Michael Buchanan -
Number of replies: 2

I am using Moodle 1.98.  I'm a trying to open a pop-up window using javascript on the log-in page.  In other words - in the instructions area on the right side of the log-in page, I want to have a link that when clicked will open the page is a smaller window.

I tried putting the following code into the instruction box on the administration/users/authentication/manage authentication page, but when I click on the link, the page opens but it opens in the same window.  Is my code wrong?  Is there a better way to open a sizable window?

 

<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=680,height=550,scrollbars=no');
return false;
}
//-->
</SCRIPT>

<body>
<A HREF="../new_user/new_user.html"
XonClick="return popup(this, 'notes')">my popup</A>
</body>

Average of ratings: -
In reply to Michael Buchanan

Re: Want to create popup window from login page (using javascript)

by Lynn Scarlet Clark -

Hello Michael,

That looks a little more complex than perhaps you need. Moodle doesn't really 'like' javascript so anything you can put it which as as bare bones as you can get is preferable.

Try adding this to the right point in your moodle.php page (I edit mine via languge editing, rather than Myphp etc):

At top:

<script type="text/javascript" language="javascript"> <!-- function popitup(url) { newwindow=window.open(url,'name','height=550,width=680, scrollbars=1, resizeable=1'); if (window.focus) {newwindow.focus()} return false;} //-->


Below:

<a onclick="function onclick(event) { return popitup("location/filename.html"); }" href="location/filename.html">Click here for sizeable window</a>

Also, I've not tried putting in JS in the log in page before, it may be that this page necessarily restricts its use. So, if this is true and unless you are able to break the page and force JS you won't get it to work at all.

Another factor may be browser specific problems. Have a try and get back to us.

In reply to Lynn Scarlet Clark

Re: Want to create popup window from login page (using javascript)

by Michael Buchanan -

Hi Scarlet,

When you say, add the script to the right point in moodle.php, where exactly do you mean?  I tried editing moodle.php directly, putting it at various places at the top but it always broke the site.  Is there a specific langauge string where I should put it?

Thanks!