Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1292 How can I adapt the dictionary popup article to accept a phrase which may or may not include space?

irt.org | Knowledge Base | JavaScript | Window | Q1292 [ previous next ]

Q1292 How can I adapt the dictionary popup article to accept a phrase which may or may not include space?

Try:

<script language="JavaScript"><!--
function def(word) {
    if (word == 'around the world') {
        word = escape(word);
        type = 'adverb';
        definition = 'An expression'
    }

    var filename = 'def.htm' + '?' + word + '|' + type + '|' + definition;
    myFloater = window.open(filename,'myWindow','scrollbars=no,status=no,width=300,height=200')
}
//--></script>

<p>
<a href="javascript:def('around the world')" onMouseOver="status='';return true">around the world</a>
the world.
</p>

And in def.htm:

<body>

<script language="JavaScript"><!--
function strip(string) {
    var first  = string.indexOf("|");
    var second = string.indexOf("|",first+1);
    outputDefinition(string.substring(0,first),
                     string.substring(first+1,second),
                     string.substring(second+1,string.length));
}
//--></script>

<script language="JavaScript1.1"><!--
function strip(string) {
    var myArray = string.split('|');
    outputDefinition(myArray[0],myArray[1],myArray[2]);
}
//--></SCRIPT>

<script language="JavaScript"><!--
function outputDefinition(word,type,definition) {
    document.write('<big>' + unescape(word) + '<\/big><br>');
    document.write('<i>' + unescape(type) + '<\/i><br>');
    document.write(unescape(definition));
}

strip(self.location.search.substring(1));
//--></script>

</body>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.