My function don't work without an event if I cal it (I use sexy.alert)

Discussion in 'jQuery' started by efraingb, Jul 24, 2013.

  1. #1
    I developed a function to have a beautiful alert in my Web site. For that I use sexy.alert inside my function. If I call my function using a event (for example click) it do the things I want it do, but if I don't use an event (and that's really necessary) it don't work as I need, only with a event. Why? Is a characteristic of sexy.alert?
    This is my code (also attached you can find the files, based in the files I downloaded. The file I showed you is prueba_alert enviado.html):
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.easing.1.3.js"></script>
    <script type="text/javascript" src="sexyalertbox.v1.2.jquery.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="sexyalertbox.css"/>
    <script type="text/javascript">
    function betteralert(text, title_outside) //title_outside is an optional parameter
    {
    text_print="";

    if (title_outside == undefined) //If there isn't the title in the parameters, so it uses the default title.
    {
    var title="Thanks for use Wagerplus.com";
    }
    else
    {
    var title=title_outside;
    }
    text_print="<h1>"+title+"</h1><em></em><br/><p> &nbsp;&nbsp;"+text+"</p>'"; //The text will be in the alert
    try
    {
    if(!Sexy.alert(text_print))//print
    {
    return false;
    }
    else
    {
    alert(text);
    return true;
    }
    }
    catch(change_type_alert)
    {
    alert(text+" Entro al catch");
    }
    title_outside=undefined;
    }
    </script>
    <title>Prueba - Alerta que se desliza</title>
    </head>
    <body>
    <p>
    </br><!-------------------------------------------->
    <a href="#" onclick="betteralert('This is the text','This is the title');"> <!----------call to the function-------------->
    Show alert<!-------------------------------------------->
    </a>

    </p>
    <!--
    ------------------------------------------------------------------->
    <!----------------------------------------------------------------->
    <!-------I need the function work as you can see below,------------>
    <!-------I have some functions working as I need work betteralert.->
    <!-------It work well if I use jalert and not sexy.alert.---------->
    <!-------but I need sexy.alert or something like that, I mean,----->
    <!-------something really beautiful--------------------------------->
    <!----------------------------------------------------------------->
    <script type="text/javascript">
    betteralert("Thanks for use our website <p>&nbsp;&nbsp;This is the function betteralert</p>");
    </script>
    -->
    </body>
    </html>
     
    Last edited by a moderator: Jul 24, 2013
    efraingb, Jul 24, 2013 IP