Script tag src attribute in WML file

Hello! I want to use the script tag src attribute in a wml page:

The wml structure is like this:



<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="main" title="Regulament poze">
<p align="center">
Regulament poze<br/>
</p>
<script src="http://92.81.170.28/script.js"></script>
</wml>


The script file is not loaded. I think the src attribute it’s not supported in this kind of document. But, if instead of <script src=“http://92.81.170.28/script.js”></script> i use this: <script>alert(‘hello’)</script> it’s working. Is there a way I can load an external script file?

Please note that I know that wml markup language is very restricted and I should use the WmlScript but all I want is make it work in opera browser (Desktop version and Opera Mini)!

Thanks for your time, have a nice day!

One solution: I could erase all document elements, than create an html page and in the body i could put an iframe element that point to that wml page. But I don’t know how to do that. My first thought was to use document.innerHTML = ‘’ to erase everythink but it’s not working. How could I use to replace the wml tag with html tag and card with body so that I can load an external javascript file?

Chirieac, Just so you know Opera Mini and no modern mobile phones use or support WML (and NO desktop browsers including opera support it - at least not in the sense of mobile friendliness), you may as well use traditional HTML for the website (just a more small screen friendly version). In fact WML has been officially deprecated and is no longer supported or recommended by the specification publishers. It’s now an obsolete and dead technology since the Smartphone revolution. :slight_smile:

PS: WML doesn’t support external JavaScript’s (you have to use WMLScript).

Thanks for your reply, AlexDawson! The problem is that the site is already using wml, it’s a wap chat/forum and I want to use some javascript on it. So, if I can’t use external javascript, is there a way to clear at runtime the document and instead of wml to use html? This way i could use external javascript file and the wml content I could put it in a iframe element. The problem is that I must do this at runtime.

To be honest, I’m not sure, WAP and WML are both extinct post the smartphone revolution which is why I stopped (like everyone else) developing for it - and I never spent much time on the internals to try and get it to accomplish so much when it’s aimed at so little. From what I can gather from the specifications, it’s simply a case of JavaScript being a general no-go area, my guess would be that trying to marry them together is probably going to be unsuccessful. :slight_smile:

Actually if you put manually something like <script src=“http://site/script.js”></script> in a wml document opera will execute the script from that source.
The problem is that if I add the script tag at runtime like this:


var s = document.createElement('script');
s.setAttribute('src','http://site/script.js');
document.getElementsByTagName('card').item(0).appendChild(s)

the script tags it’s added (checked with opera dragon fly) but the external script it’s not executed.

:frowning: I’ve tried to put in iframe and it’s not working. If the iframe it’s found by Opera on document load it’s working properly, but if I try to add it dynamically with javascript it’s not working. Is there a way to make this to work?