Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Window | Q1292 [ previous next ]

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>

©2018 Martin Webb