Senior Member
Join Date: Oct 2011
Posts: 865
|
Unfortunately, it appears that the RW Javascript engine is based on IE, but isnt neccesarilly the one of your IE. I know this because i wrote a more complex script, using things like document.getElementByID().getElementsByClassName()
It works in IE, no errors, but not in RW. Im guessing the document model isnt available to the inline RW. I'm unable to get it to works with RW, but it looks like you cant trust that it works in the browser of IE to work with RW. That fact that RW uses the same UserAgent is one thing, but it might have a different Javascript engine. dont know enough about it. Or it might be more sensitive t something im missing... could be my markup (HTML) dont know. EDIT: Here is another version, that doesnt use the document model, but basic form, with two fields instead of one. Im wondering if its failing due to either a markup issue, or maybe something to do with multiple statements on one action. Again, this works in both chrome and IE, but now RW. Not sure. Code:
<HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Varisia Caravan Encounters</TITLE> </HEAD> <BODY> <script language="JavaScript"> // Some Arrays rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.today=new Date(); rnd.seed=rnd.today.getTime(); rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); } function rand(number) { return Math.ceil(rnd()*number); } function tableResults(argument, sectionIdentifier) { var varisiaArray = []; varisiaArray.push({"max": 15, "name": "Bad Weather", "content": "Fog, rain, high winds, or some other form of bad weather slows the caravan, reducing its overall speed by half for the day unless the caravan makes a DC 12 Security check." }); varisiaArray.push({"max": 30, "name": "Bandit Ambush (CR 2)", "content": "The caravan must make a DC 15 Security check to notice this ambush in time to react; if this check fails, the caravan takes a –2 penalty to its Armor Class and on attack rolls for the first round of combat. The ambushers could be a group of bandits, a gang of highwaymen, or even a small tribe of Nolander barbarians. Regardless of their makeup, the ambushers’ stats and aggression are identical (AC 14; hp 20; Attack +4; Damage 2d6+3). They fight to the death. If defeated, 1 cargo unit of treasure worth 250 gp can be recovered."}); varisiaArray.push({"max": 50, "name": "Goblin Raiders (CR 1/2)", "content": "A shrieking band of goblins wielding dogslicers and broken branches attacks the caravan (AC 11; hp 10; Attack +1; Damage 1d8). If the PCs have a horse train, the goblins are more timid than normal and take a –2 penalty on attack rolls. If defeated, a search of the goblins reveals a single cargo unit of treasure worth 125 gp."}); varisiaArray.push({"max": 55, "name": "Ogre Assault (CR 3)", "content": "A small band of ogres lumbers out of the surrounding foliage to attack the caravan (AC 15; hp 30; Attack +6; Damage 3d4+6). The ogres flee if reduced below 10 hit points. If they are slain, looting produces 2 cargo units of treasure worth 400 gp each."}); varisiaArray.push({"max": 65, "name": "Treacherous Road", "content": "The road conditions become hazardous. They might be muddy, partially flooded, or even blocked by a fallen tree. The caravan must make a DC 14 Security check or lose 2d6 miles of progress for the day as the situation is dealt with."}); varisiaArray.push({"max": 100,"name": "Varisian Caravan", "content": "The PCs encounter another Varisian caravan heading in the opposite direction. With a DC 12 Resolve check, the PCs can befriend the other caravan. If this encounter occurs during the day, the caravan can give the PCs advice as to what lies ahead, reducing the chance of an encounter to 5% per day for the next 1d6 days. If the encounter occurs during the evening, the caravan agrees to share their camp, allowing the PCs to trade with them. The caravan can purchase up to 2,000 gp in objects, and can offer anything worth 600 gp or less for sale."}); var allArrays = { "varisia": varisiaArray, }; var randomNum = rand(100) + 1; var arrayOfChoices = allArrays[argument]; var error = ""; if (!arrayOfChoices) { error = "no such set: " + argument; } var content = ""; var name = ""; for (var itemIndex in arrayOfChoices) { var item = arrayOfChoices[itemIndex]; if (randomNum <= item.max) { content = item.content; name = item.name break; } } var results = []; if (error) { results.name = ""; results.content = error; } else { results.name = name; results.content = content; } return results; } </script> <div id="error"></div> <form> <input type="button" name="Button1" value="Varisia Caravan Encounters" onClick="var x = tableResults('varisia');this.form.name.value=x.name;this.form.content.value = x.content;" size="" /> <input name="name" style="font-weight:bold;"></input> <textarea name="content" cols="40" rows="10" wrap="soft"></textarea> </form> Last edited by mirtos; August 10th, 2014 at 07:55 PM. |
#31 |
Senior Member
Lone Wolf Staff
Join Date: Jun 2011
Posts: 1,090
|
Quote:
http://stackoverflow.com/questions/4...into-standards I believe the intent is that when a program with an embedded browser control (such as Realm Works) runs on different computers that have different versions of IE installed, they will behave the same and you won't have differences in behavior. But it also means it sets things to a lowest common denominator type of setting. |
|
#32 |
Senior Member
Join Date: Oct 2011
Posts: 865
|
makes sense that they would do that, though from what i imagine, it would be very surprised if it behaved as IE 6. Microsoft stopped supporting that a long time ago, and is very adamant about getting people off of it, and I doubt they would want any other software to be using it. Its probably an IE 8 or something like that.
|
#33 |
Senior Member
Lone Wolf Staff
Join Date: Jun 2011
Posts: 1,090
|
Quote:
|
|
#34 |
Senior Member
Join Date: Oct 2011
Posts: 865
|
Quote:
Quote:
Seems odd to be using a different rendering mode. But anyway, we arent talking about rendering mode, i dont think anyway, just what JS methods are available. Im going to do a test when i get home, see if a jquery page will work. (granted that will require internet access as Parody mentions) |
||
#35 |
Senior Member
Lone Wolf Staff
Join Date: Jun 2011
Posts: 1,090
|
Quote:
One thing you might be able to do, to prevent the need for Internet access, is once you have created your page, save it as a web archive file. I believe that will bundle all of the resources together into a single file. |
|
#36 |
Senior Member
Join Date: Oct 2011
Posts: 865
|
You're generally right about USer Agents affecting JS engines, but I was using pretty basic stuff. Still, I dont know for sure if its an IE 7 thing. Unfortunately my version of IE doesnt let me emulate IE 7 for testing.
The web archive thing is a very interesting thought... ill give that a try. loading in the jquery library would make things a lot easier as it handles most browser checks (It would make the storage in the database very big, though it would add 100K to each web page.). I assume its impossible to get RealmsWorks to show JS errors? (its more of curiosity thing for me than a need thing) |
#37 |
Senior Member
Join Date: Jan 2013
Location: Rochester, MN
Posts: 1,516
|
Some of this probably duplicates everyone else's research, but:
Poking around it appears that the default for the WebBrowser control is to tell IE to handle everything like IE 7. So there's things like this StackOverflow question that shows how to do getElementsByClassName() in IE7 and IE8. You can override this via the registry, if you know exactly which version of IE you want. You can also override it in your own pages by using a meta right after <head>. This one makes it run your page using the latest version of IE on your system: Code:
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> Unfortunately, we don't know which version of IE will be installed on the system; IE7 is possible on both XP and Vista, and IE8 on 7. So you're still stuck working around things. At least we have a baseline? |
#38 |
Senior Member
Join Date: Oct 2011
Posts: 865
|
this is why i was thinking that something like a jquery library would be the best. It handles all of that much better than most of us could on our own. On the other hand, it means each web page you do will be 100K bigger...
its also much more readable when doing multiple parent levels. but i feel stupid for not doing the meta tag.. i know that. doh. IE 7 javascript sucks. IE 8 and more are so much better. I wonder why my last script didnt work though. I wasnt doing getElementsByClassname.. just assigning multiple variables in a onclick ... i wonder if IE 7 cant deal with that. (its been over 12 months since ive had to deal with pre IE 8 issues... so glad my company no longer supports it) |
#39 |
Senior Member
Join Date: Jan 2013
Location: Rochester, MN
Posts: 1,516
|
Quote:
|
|
#40 |
|
|