I personally would never have done such a thing to a Koran and would have counseled JP2 against doing it, but whatever painful ambiguity involved should have been washed away by his super-clear and unambiguous teaching encyclicals Redemptor hominis "The Redeemer of Man" (on Jesus' unique and irreplaceable role as the Savior of the World) and Redemptoris missio "Mission of the Redeemer" (on the permanent urgency of the Church's missionary mandate to carry out the Great Commission to bring the whole world to Christ.)
Incidentally, I might not be so quick to give a "benefit of the doubt" to Pope Francis making a similar gesture. I hope I am not being unfair, but it would be because Pope Francis seems both unwilling and unable to make crystal-clear doctrinal statements on anything --- his intent, even according to his own explanation, seems to be to create new ambiguities, which is a hugely severe problem: "God is not the Author of confusion".
Pope John Paul II however did invoke:
"May Saint John Baptist protect Islam and all the people of Jordan, and all who partecipated in this celebration, a memorable celebration", on March 21, 2000. It's on the Vatican website. VISIT TO WADI AL-KHARRAR
And I consider JP II's 1986 Assisi Apostasy to be a precedent, a compliment, and no different from today's apostasy by Bergoglio.